org.eclipse.rdf4j.federated.algebra.SingleSourceQuery Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rdf4j-tools-federation Show documentation
Show all versions of rdf4j-tools-federation Show documentation
A federation engine for virtually integrating SPARQL endpoints
/*******************************************************************************
* Copyright (c) 2019 Eclipse RDF4J contributors.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
package org.eclipse.rdf4j.federated.algebra;
import java.util.Set;
import org.eclipse.rdf4j.common.order.AvailableStatementOrder;
import org.eclipse.rdf4j.federated.endpoint.Endpoint;
import org.eclipse.rdf4j.federated.structures.QueryInfo;
import org.eclipse.rdf4j.query.algebra.AbstractQueryModelNode;
import org.eclipse.rdf4j.query.algebra.QueryModelNode;
import org.eclipse.rdf4j.query.algebra.QueryModelVisitor;
import org.eclipse.rdf4j.query.algebra.TupleExpr;
import org.eclipse.rdf4j.query.algebra.Var;
/**
* A query which has a single relevant source. These queries can be sent entirely to the endpoint as-is.
*
* @author Andreas Schwarte
*/
public class SingleSourceQuery extends AbstractQueryModelNode implements TupleExpr, QueryRef {
private static final long serialVersionUID = 5745172129911897271L;
private final TupleExpr parsedQuery;
private final transient Endpoint source;
private final transient QueryInfo queryInfo;
/**
* @param parsedQuery
* @param source
* @param queryInfo
*/
public SingleSourceQuery(TupleExpr parsedQuery, Endpoint source,
QueryInfo queryInfo) {
super();
this.parsedQuery = parsedQuery;
this.source = source;
this.queryInfo = queryInfo;
}
public Endpoint getSource() {
return source;
}
public String getQueryString() {
return queryInfo.getQuery();
}
@Override
public QueryInfo getQueryInfo() {
return queryInfo;
}
@Override
public void visit(QueryModelVisitor visitor)
throws X {
visitor.meetOther(this);
}
@Override
public void visitChildren(QueryModelVisitor visitor)
throws X {
parsedQuery.visit(visitor);
}
@Override
public void replaceChildNode(QueryModelNode current, QueryModelNode replacement) {
throw new UnsupportedOperationException();
}
@Override
public String getSignature() {
return super.getSignature() + " @" + source.getId();
}
@Override
public Set getBindingNames() {
return parsedQuery.getBindingNames();
}
@Override
public Set getAssuredBindingNames() {
return parsedQuery.getAssuredBindingNames();
}
@Override
public SingleSourceQuery clone() {
return (SingleSourceQuery) super.clone();
}
@Override
public Set getSupportedOrders(AvailableStatementOrder tripleSource) {
return parsedQuery.getSupportedOrders(tripleSource);
}
@Override
public void setOrder(Var var) {
parsedQuery.setOrder(var);
}
@Override
public Var getOrder() {
return parsedQuery.getOrder();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy