Class 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 the Repository to communicate with a SPARQL endpoint.
    Author:
    Andreas Schwarte
    • Field Detail

      • boundJoinBlockSize

        protected int boundJoinBlockSize
        The number of bindings sent in a single subquery in evaluate(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 used
        shutDown - a flag indicating whether the repository shall be closed in shutdown()
    • Method Detail

      • select

        public org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet> select​(org.eclipse.rdf4j.query.algebra.Service service,
                                                                                                                Set<String> projectionVars,
                                                                                                                org.eclipse.rdf4j.query.BindingSet bindings,
                                                                                                                String baseUri)
                                                                                                         throws org.eclipse.rdf4j.query.QueryEvaluationException
        Evaluate the provided sparqlQueryString at the initialized Repository of this FederatedService. Insert bindings into SELECT query and evaluate
        Specified by:
        select in interface org.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.QueryEvaluationException
        Evaluate the provided sparqlQueryString at the initialized Repository of this FederatedService. Insert bindings, send ask query and return final result
        Specified by:
        ask in interface org.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> evaluate​(org.eclipse.rdf4j.query.algebra.Service service,
                                                                                                                  org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet> bindings,
                                                                                                                  String baseUri)
                                                                                                           throws org.eclipse.rdf4j.query.QueryEvaluationException
        Specified by:
        evaluate in interface org.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> evaluateInternal​(org.eclipse.rdf4j.query.algebra.Service service,
                                                                                                                             org.eclipse.rdf4j.common.iteration.CloseableIteration<org.eclipse.rdf4j.query.BindingSet> bindings,
                                                                                                                             String baseUri)
                                                                                                                      throws org.eclipse.rdf4j.query.QueryEvaluationException
        Evaluate the SPARQL query that can be constructed from the SERVICE node at the initialized Repository of this FederatedService. 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 the ROW_IDX_VAR projection if it is not already present.
        Parameters:
        queryString - the SELECT query string from the SERVICE node
        valuesClause - the constructed VALUES clause
        Returns:
        the final String
      • initialize

        public void initialize()
                        throws org.eclipse.rdf4j.query.QueryEvaluationException
        Specified by:
        initialize in interface org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedService
        Throws:
        org.eclipse.rdf4j.query.QueryEvaluationException
      • isInitialized

        public boolean isInitialized()
        Specified by:
        isInitialized in interface org.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 fresh RepositoryConnection for each individual query
      • shutdown

        public void shutdown()
                      throws org.eclipse.rdf4j.query.QueryEvaluationException
        Specified by:
        shutdown in interface org.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