Class RepositoryFederatedService
- java.lang.Object
-
- org.eclipse.rdf4j.repository.sparql.federation.RepositoryFederatedService
-
- All Implemented Interfaces:
org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedService
- Direct Known Subclasses:
SPARQLFederatedService
public class RepositoryFederatedService extends Object implements org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedService
Federated Service wrapping theRepositoryto communicate with a SPARQL endpoint.- Author:
- Andreas Schwarte
-
-
Field Summary
Fields Modifier and Type Field Description protected intboundJoinBlockSizeThe number of bindings sent in a single subquery inevaluate(Service, CloseableIteration, String)If blockSize is set to 0, the entire input stream is used as block input the block size effectively determines the number of remote requestsprotected booleanshutDown
-
Constructor Summary
Constructors Constructor Description RepositoryFederatedService(Repository repo)RepositoryFederatedService(Repository repo, boolean shutDown)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanask(org.eclipse.rdf4j.query.algebra.Service service, org.eclipse.rdf4j.query.BindingSet bindings, String baseUri)Evaluate the provided sparqlQueryString at the initializedRepositoryof thisFederatedService.org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException>evaluate(org.eclipse.rdf4j.query.algebra.Service service, org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException> bindings, String baseUri)protected org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException>evaluateInternal(org.eclipse.rdf4j.query.algebra.Service service, org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException> bindings, String baseUri)Evaluate the SPARQL query that can be constructed from the SERVICE node at the initializedRepositoryof thisFederatedService.intgetBoundJoinBlockSize()protected RepositoryConnectiongetConnection()Retrieve a (re-usable) connection.voidinitialize()protected StringinsertValuesClause(String queryString, String valuesClause)Insert the constructed VALUES clause in the beginning of the WHERE block.booleanisInitialized()org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException>select(org.eclipse.rdf4j.query.algebra.Service service, Set<String> projectionVars, org.eclipse.rdf4j.query.BindingSet bindings, String baseUri)Evaluate the provided sparqlQueryString at the initializedRepositoryof thisFederatedService.voidsetBoundJoinBlockSize(int boundJoinBlockSize)voidsetUseFreshConnection(boolean flag)voidshutdown()
-
-
-
Field Detail
-
boundJoinBlockSize
protected int boundJoinBlockSize
The number of bindings sent in a single subquery inevaluate(Service, CloseableIteration, String)If blockSize is set to 0, the entire input stream is used as block input the block size effectively determines the number of remote requests
-
shutDown
protected boolean shutDown
-
-
Constructor Detail
-
RepositoryFederatedService
public RepositoryFederatedService(Repository repo)
- Parameters:
repo- the repository to be used
-
RepositoryFederatedService
public RepositoryFederatedService(Repository repo, boolean shutDown)
- Parameters:
repo- the repository to be usedshutDown- a flag indicating whether the repository shall be closed inshutdown()
-
-
Method Detail
-
select
public org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException> select(org.eclipse.rdf4j.query.algebra.Service service, Set<String> projectionVars, org.eclipse.rdf4j.query.BindingSet bindings, String baseUri) throws org.eclipse.rdf4j.query.QueryEvaluationExceptionEvaluate the provided sparqlQueryString at the initializedRepositoryof thisFederatedService. Insert bindings into SELECT query and evaluate- Specified by:
selectin interfaceorg.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedService- Throws:
org.eclipse.rdf4j.query.QueryEvaluationException
-
ask
public boolean ask(org.eclipse.rdf4j.query.algebra.Service service, org.eclipse.rdf4j.query.BindingSet bindings, String baseUri) throws org.eclipse.rdf4j.query.QueryEvaluationExceptionEvaluate the provided sparqlQueryString at the initializedRepositoryof thisFederatedService. Insert bindings, send ask query and return final result- Specified by:
askin interfaceorg.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedService- Throws:
org.eclipse.rdf4j.query.QueryEvaluationException
-
evaluate
public org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException> evaluate(org.eclipse.rdf4j.query.algebra.Service service, org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException> bindings, String baseUri) throws org.eclipse.rdf4j.query.QueryEvaluationException- Specified by:
evaluatein interfaceorg.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedService- Throws:
org.eclipse.rdf4j.query.QueryEvaluationException
-
evaluateInternal
protected org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException> evaluateInternal(org.eclipse.rdf4j.query.algebra.Service service, org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException> bindings, String baseUri) throws org.eclipse.rdf4j.query.QueryEvaluationExceptionEvaluate the SPARQL query that can be constructed from the SERVICE node at the initializedRepositoryof thisFederatedService. Use specified bindings as constraints to the query. Try to evaluate using VALUES clause, if this yields an exception fall back to the naive implementation. This method deals with SILENT SERVICEs.- Throws:
org.eclipse.rdf4j.query.QueryEvaluationException
-
insertValuesClause
protected String insertValuesClause(String queryString, String valuesClause)
Insert the constructed VALUES clause in the beginning of the WHERE block. Also adds theROW_IDX_VARprojection if it is not already present.- Parameters:
queryString- the SELECT query string from the SERVICE nodevaluesClause- the constructed VALUES clause- Returns:
- the final String
-
initialize
public void initialize() throws org.eclipse.rdf4j.query.QueryEvaluationException- Specified by:
initializein interfaceorg.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedService- Throws:
org.eclipse.rdf4j.query.QueryEvaluationException
-
isInitialized
public boolean isInitialized()
- Specified by:
isInitializedin interfaceorg.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedService
-
getBoundJoinBlockSize
public int getBoundJoinBlockSize()
-
setBoundJoinBlockSize
public void setBoundJoinBlockSize(int boundJoinBlockSize)
- Parameters:
boundJoinBlockSize- the bound join block size, 0 to evaluate all in a single request
-
setUseFreshConnection
public void setUseFreshConnection(boolean flag)
- Parameters:
flag- whether to use a freshRepositoryConnectionfor each individual query
-
shutdown
public void shutdown() throws org.eclipse.rdf4j.query.QueryEvaluationException- Specified by:
shutdownin interfaceorg.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedService- Throws:
org.eclipse.rdf4j.query.QueryEvaluationException
-
getConnection
protected RepositoryConnection getConnection() throws RepositoryException
Retrieve a (re-usable) connection. If it is not yet created, open a fresh connection. Note that this connection is closed automatically when shutting this service.- Returns:
- connection
- Throws:
RepositoryException
-
-