Class RepositoryFederatedService

    • Field Detail

      • logger

        static final org.slf4j.Logger logger
      • 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
      • useFreshConnection

        private boolean useFreshConnection
        Whether to use a fresh repository connection for individual queries
      • 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 CloseableIteration<BindingSet,​QueryEvaluationException> select​(Service service,
                                                                                    java.util.Set<java.lang.String> projectionVars,
                                                                                    BindingSet bindings,
                                                                                    java.lang.String baseUri)
                                                                             throws QueryEvaluationException
        Evaluate the provided sparqlQueryString at the initialized Repository of this FederatedService. Insert bindings into SELECT query and evaluate
        Specified by:
        select in interface FederatedService
        Parameters:
        service - the reference to the service node, contains additional meta information (vars, prefixes)
        projectionVars - The variables with unknown value that should be projected from this evaluation
        bindings - the bindings serving as additional constraints
        Returns:
        an iteration over the results of the query
        Throws:
        QueryEvaluationException - If there was an exception generated while evaluating the query.
      • ask

        public boolean ask​(Service service,
                           BindingSet bindings,
                           java.lang.String baseUri)
                    throws 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 FederatedService
        Parameters:
        service - the reference to the service node, contains additional meta information (vars, prefixes)
        bindings - the bindings serving as additional constraints
        Returns:
        true if at least one result exists
        Throws:
        QueryEvaluationException - If there was an exception generated while evaluating the query.
      • insertValuesClause

        protected java.lang.String insertValuesClause​(java.lang.String queryString,
                                                      java.lang.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
      • 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
      • 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
      • getRelevantBindingNames

        private java.util.List<java.lang.String> getRelevantBindingNames​(java.util.List<BindingSet> bindings,
                                                                         java.util.Set<java.lang.String> serviceVars)
        Compute the relevant binding names using the variables occurring in the service expression and the input bindings. The idea is find all variables which need to be projected in the subquery, i.e. those that will not be bound by an input binding.

        If the resulting list is empty, the cross product needs to be formed.

        Parameters:
        bindings -
        serviceVars -
        Returns:
        the list of relevant bindings (if empty: the cross product needs to be formed)
      • buildVALUESClause

        private java.lang.String buildVALUESClause​(java.util.List<BindingSet> bindings,
                                                   java.util.List<java.lang.String> relevantBindingNames)
                                            throws QueryEvaluationException
        Computes the VALUES clause for the set of relevant input bindings. The VALUES clause is attached to a subquery for block-nested-loop evaluation. Implementation note: we use a special binding to mark the rowIndex of the input binding.
        Parameters:
        bindings -
        relevantBindingNames -
        Returns:
        a string with the VALUES clause for the given set of relevant input bindings
        Throws:
        QueryEvaluationException