Class ExecOpSequentialBindJoinSPARQLwithVarRenaming

All Implemented Interfaces:
StatsProvider, ExecutableOperator, UnaryExecutableOp

public class ExecOpSequentialBindJoinSPARQLwithVarRenaming extends BaseForExecOpSequentialBindJoinSPARQL
Implementation of the sequential, batch-based bind-join algorithm that uses UNION clauses with variable renaming (as proposed in the FedX paper by Schwarte et al. 2011, where it is called "bound join"). The variable that is renamed can be any non-join variable. For more details about the actual implementation of the algorithm, and its extra capabilities, refer to BaseForExecOpSequentialBindJoin.
  • Field Details

    • pattern

      protected final org.apache.jena.sparql.syntax.Element pattern
    • solMapsList

      protected final List<org.apache.jena.sparql.engine.binding.Binding> solMapsList
    • renamedVar

      protected final org.apache.jena.sparql.core.Var renamedVar
    • renamedVarPrefix

      protected final String renamedVarPrefix
  • Constructor Details

    • ExecOpSequentialBindJoinSPARQLwithVarRenaming

      public ExecOpSequentialBindJoinSPARQLwithVarRenaming(SPARQLGraphPattern query, SPARQLEndpoint fm, ExpectedVariables inputVars, boolean useOuterJoinSemantics, int batchSize, boolean collectExceptions, QueryPlanningInfo qpInfo)
      Parameters:
      query - - the graph pattern to be evaluated (in a bind-join manner) at the federation member given as 'fm'
      fm - - the federation member targeted by this operator
      inputVars - - the variables to be expected in the solution mappings that will be pushed as input to this operator
      useOuterJoinSemantics - - true if the 'query' is to be evaluated under outer-join semantics; false for inner-join semantics
      batchSize - - the number of solution mappings to be included in each bind-join request; this value must not be smaller than BaseForExecOpSequentialBindJoin.minimumRequestBlockSize
      collectExceptions - - true if this operator has to collect exceptions (which is handled entirely by one of the super classes); false if the operator should immediately throw every ExecOpExecutionException
      qpInfo - - the QueryPlanningInfo object that was populated for a physical plan whose root operator was the physical operator for which this executable operator was created
  • Method Details

    • getVarForRenaming

      public org.apache.jena.sparql.core.Var getVarForRenaming(SPARQLGraphPattern query, ExpectedVariables inputVars)
      Finds a variable in the given query that is not present in the expected input variables and can be used as a variable for renaming. The method iterates through the certain variables of the given SPARQL graph pattern and returns the first variable that is neither listed as a certain variable nor a possible variable among the input variables.
      Parameters:
      query - the SPARQL graph pattern containing the query variables
      inputVars - the input variables
      Returns:
      a Var that can be used as a variable for renaming, or null if no such variable is found
    • createExecutableReqOp

      protected NullaryExecutableOp createExecutableReqOp(Set<org.apache.jena.sparql.engine.binding.Binding> solMaps)
      Description copied from class: BaseForExecOpSequentialBindJoin
      Implementations of this function should create an executable operator that can perform a bind join request in which the query of this bind join operator is combined with the given solution mappings. Implementations can assume that the given solution mappings are already restricted to contain bindings only for the join variables, that none of the given solution mappings contains blank nodes, that none of the given solution mappings is the empty solution mapping, and that the given set of solution mappings is duplicate free and nonempty. The operator created by this function should throw exceptions instead of collecting them.
      Specified by:
      createExecutableReqOp in class BaseForExecOpSequentialBindJoin<SPARQLGraphPattern,SPARQLEndpoint>
    • createUnion

      protected org.apache.jena.sparql.syntax.Element createUnion(Iterable<org.apache.jena.sparql.engine.binding.Binding> solMaps)
    • createMySink

    • renameVar

      public static org.apache.jena.sparql.syntax.Element renameVar(SPARQLGraphPattern pattern, org.apache.jena.sparql.core.Var oldVar, org.apache.jena.sparql.core.Var newVar)
      Renames all occurences of variable within a SPARQL graph pattern element.
      Parameters:
      pattern - the SPARQL graph pattern in which to rename the variable
      oldVar - the variable to be replaced
      newVar - the variable to replace oldVar
      Returns:
      the modified element
    • renameVar

      public static org.apache.jena.sparql.engine.binding.Binding renameVar(org.apache.jena.sparql.engine.binding.Binding binding, org.apache.jena.sparql.core.Var oldVar, org.apache.jena.sparql.core.Var newVar)
      Renames a variable within a single Jena binding. Iterates over all (variable, value) pairs in the original binding and builds a new binding the occurrence of oldVar is replaced by newVar.
      Parameters:
      binding - the original binding
      oldVar - the variable to replace
      newVar - the new variable name
      Returns:
      a new binding
    • resolveRenamedVarAndMerge

      public org.apache.jena.sparql.engine.binding.Binding resolveRenamedVarAndMerge(org.apache.jena.sparql.engine.binding.Binding sm)
      Finds the renamed variable in the given solution mapping, parses its numerical suffix as an index, renames that variable, and merges the result with the corresponding entry in solMapsList.
      Parameters:
      sm - the incoming solution mapping
      Returns:
      a new solution mapping that has been renamed and merged
      Throws:
      IllegalArgumentException - if no renamed variable is found