Class SolutionMappingsHashTableBasedOnOneVar

java.lang.Object
se.liu.ida.hefquin.base.datastructures.impl.SolutionMappingsIndexBase
se.liu.ida.hefquin.base.datastructures.impl.SolutionMappingsHashTableBasedOnOneVar
All Implemented Interfaces:
Iterable<SolutionMapping>, Collection<SolutionMapping>, SolutionMappingsIndex, StatsProvider

public class SolutionMappingsHashTableBasedOnOneVar extends SolutionMappingsIndexBase
This is a hash table based implementation of SolutionMappingsIndex that can be used for indexes that are built on one query variable and that are meant to be used for cases in which adding and probing into the index may not happen concurrently. As mentioned above, this implementation assumes that adding and probing into the index may not happen concurrently. Based on this assumption, for every method that returns an Iterable of solution mappings, the Iterable that it returns is directly based on an internal data structure (rather than being a new Iterable into which the solution mappings have been copied). For cases in which the assumption does not hold (i.e., cases in which adding and probing into the index may actually happen concurrently), an object of this class may simply be wrapped in a SolutionMappingsIndexForMixedUsage which then creates a new Iterable for every Iterable returned by this implementation. Another assumption of this implementation is that the only variable relevant for index look-ups is the variable on which the index is built. In other words, the assumption is that the only variable that the solution mappings added to the index have in common with the solution mappings given to the method getJoinPartners(SolutionMapping) is the variable on which the index is built. For cases in which this assumption does not hold, a SolutionMappingsIndexWithPostMatching can be used to wrap a SolutionMappingsHashTableBasedOnOneVar.
  • Field Details

    • map

      protected final Map<org.apache.jena.graph.Node,List<SolutionMapping>> map
    • joinVar

      protected final org.apache.jena.sparql.core.Var joinVar
  • Constructor Details

    • SolutionMappingsHashTableBasedOnOneVar

      public SolutionMappingsHashTableBasedOnOneVar(org.apache.jena.sparql.core.Var joinVar)
  • Method Details

    • size

      public int size()
    • isEmpty

      public boolean isEmpty()
    • contains

      public boolean contains(Object o)
    • getAllSolutionMappings

      public Iterable<SolutionMapping> getAllSolutionMappings()
      Description copied from interface: SolutionMappingsIndex
      Returns all solution mappings currently in this index.
    • add

      public boolean add(SolutionMapping e)
    • clear

      public void clear()
    • getJoinPartners

      public Iterable<SolutionMapping> getJoinPartners(SolutionMapping sm)
      This method assumes that the only variable that the given solution mapping has in common with the solution mappings in the index is the variable on which the index is built. For cases in which this assumption does not hold, the returned solution mappings are not actually join partners but only candidates for join partners; hence, they still need to be checked for compatibility with the given solution mapping. In cases in which he assumption is not guaranteed to hold, this index can be wrapped by a SolutionMappingsIndexWithPostMatching which takes care of the compatibility check.
    • findSolutionMappings

      public Iterable<SolutionMapping> findSolutionMappings(org.apache.jena.sparql.core.Var var, org.apache.jena.graph.Node value)
      Description copied from interface: SolutionMappingsIndex
      Returns an iterator over all solution mappings in this index that map the given variable to the given value. Implementations may choose to support this method only for specific variables, in which case an UnsupportedOperationException will be thrown if the method is called with an unsupported variable. The result of this method should essentially be the same as the result of calling SolutionMappingsIndex.getJoinPartners(SolutionMapping) with a solution mapping that is defined only for the given variable and that maps this variable to the given value.
    • findSolutionMappings

      public Iterable<SolutionMapping> findSolutionMappings(org.apache.jena.sparql.core.Var var1, org.apache.jena.graph.Node value1, org.apache.jena.sparql.core.Var var2, org.apache.jena.graph.Node value2)
      Description copied from interface: SolutionMappingsIndex
      Returns an iterator over all solution mappings in this index that map the first variable to the first value and the second variable to the second value. Hence, this method is a two-variables version of the method SolutionMappingsIndex.findSolutionMappings(Var, Node).
    • findSolutionMappings

      public Iterable<SolutionMapping> findSolutionMappings(org.apache.jena.sparql.core.Var var1, org.apache.jena.graph.Node value1, org.apache.jena.sparql.core.Var var2, org.apache.jena.graph.Node value2, org.apache.jena.sparql.core.Var var3, org.apache.jena.graph.Node value3)
      Description copied from interface: SolutionMappingsIndex
      This method is a three-variables version of the method SolutionMappingsIndex.findSolutionMappings(Var, Node).
    • getVarKey

      protected org.apache.jena.graph.Node getVarKey(SolutionMapping e)