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
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final List<org.apache.jena.sparql.core.Var>protected final Map<List<org.apache.jena.graph.Node>,List<SolutionMapping>> -
Constructor Summary
ConstructorsConstructorDescriptionSolutionMappingsHashTable(List<org.apache.jena.sparql.core.Var> joinVariables) SolutionMappingsHashTable(Set<org.apache.jena.sparql.core.Var> joinVariables) SolutionMappingsHashTable(org.apache.jena.sparql.core.Var... vars) -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclear()booleanfindSolutionMappings(org.apache.jena.sparql.core.Var var, org.apache.jena.graph.Node value) Returns an iterator over all solution mappings in this index that map the given variable to the given value.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) 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.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) This method is a three-variables version of the methodSolutionMappingsIndex.findSolutionMappings(Var, Node).Returns all solution mappings currently in this index.Returns an iterator over all solution mappings in this index that are compatible with the given solution mappings.protected List<org.apache.jena.graph.Node>booleanisEmpty()protected Iterable<SolutionMapping>returnLookupResultOrEmptyList(List<org.apache.jena.graph.Node> indexKey) intsize()Methods inherited from class se.liu.ida.hefquin.base.datastructures.impl.SolutionMappingsIndexBase
addAll, containsAll, findSolutionMappingsLastResort, findSolutionMappingsLastResort, findSolutionMappingsLastResort, getStats, remove, removeAll, resetStats, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArrayMethods inherited from interface se.liu.ida.hefquin.base.datastructures.SolutionMappingsIndex
iterator
-
Field Details
-
map
-
joinVariables
-
-
Constructor Details
-
SolutionMappingsHashTable
-
SolutionMappingsHashTable
public SolutionMappingsHashTable(org.apache.jena.sparql.core.Var... vars) -
SolutionMappingsHashTable
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
getAllSolutionMappings
Description copied from interface:SolutionMappingsIndexReturns all solution mappings currently in this index. -
add
-
clear
public void clear() -
getJoinPartners
Description copied from interface:SolutionMappingsIndexReturns 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 anUnsupportedOperationExceptionwill 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:SolutionMappingsIndexReturns 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 anUnsupportedOperationExceptionwill 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 callingSolutionMappingsIndex.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:SolutionMappingsIndexReturns 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 methodSolutionMappingsIndex.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:SolutionMappingsIndexThis method is a three-variables version of the methodSolutionMappingsIndex.findSolutionMappings(Var, Node). -
getVarKeys
-
returnLookupResultOrEmptyList
protected Iterable<SolutionMapping> returnLookupResultOrEmptyList(List<org.apache.jena.graph.Node> indexKey)
-