Class SolutionMappingsHashTable

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

public class SolutionMappingsHashTable extends SolutionMappingsIndexBase
This is a hash table based implementation of SolutionMappingsIndex that can be used for indexes 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 variables relevant for index look-ups are the variables on which the index is built. In other words, the assumption is that the only variables that the solution mappings added to the index have in common with the solution mappings given to the method getJoinPartners(SolutionMapping) are the variables on which the index is built. For cases in which this assumption does not hold, a SolutionMappingsIndexWithPostMatching can be used to wrap a SolutionMappingsHashTable. This implementation is generic in the sense that it can be used for an index on an arbitrary number of variables. As a consequence, it is not the most efficient implementation for cases in which the possible number of variables is fix. More efficient alternatives for the cases in which the number of variables is one or two are SolutionMappingsHashTableBasedOnOneVar and SolutionMappingsHashTableBasedOnTwoVars, respectively.
  • Field Details

    • map

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

      protected final List<org.apache.jena.sparql.core.Var> joinVariables
  • Constructor Details

    • SolutionMappingsHashTable

      public SolutionMappingsHashTable(List<org.apache.jena.sparql.core.Var> joinVariables)
    • SolutionMappingsHashTable

      public SolutionMappingsHashTable(org.apache.jena.sparql.core.Var... vars)
    • SolutionMappingsHashTable

      public SolutionMappingsHashTable(Set<org.apache.jena.sparql.core.Var> joinVariables)
  • 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)
      Description copied from interface: SolutionMappingsIndex
      Returns an iterator over all solution mappings in this index that are compatible with the given solution mappings. Implementations may choose to support this method only for specific types of solution mappings (e.g., with specific variables), in which case an UnsupportedOperationException will be thrown if the method is called with an unsupported variable.
    • 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).
    • getVarKeys

      protected List<org.apache.jena.graph.Node> getVarKeys(SolutionMapping e)
    • returnLookupResultOrEmptyList

      protected Iterable<SolutionMapping> returnLookupResultOrEmptyList(List<org.apache.jena.graph.Node> indexKey)