Class HashJoinIteration
- java.lang.Object
-
- org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<E,X>
-
- org.eclipse.rdf4j.common.iteration.LookAheadIteration<BindingSet,QueryEvaluationException>
-
- org.eclipse.rdf4j.query.algebra.evaluation.iterator.HashJoinIteration
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,CloseableIteration<BindingSet,QueryEvaluationException>
,Iteration<BindingSet,QueryEvaluationException>
public class HashJoinIteration extends LookAheadIteration<BindingSet,QueryEvaluationException>
Generic hash join implementation suitable for use by Sail implementations.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Function<BindingSet,MutableBindingSet>
bsMaker
private BindingSet
currentScanElem
private java.util.Map<BindingSetHashKey,java.util.List<BindingSet>>
hashTable
private java.util.Iterator<BindingSet>
hashTableValues
protected java.lang.String[]
joinAttributes
private CloseableIteration<BindingSet,QueryEvaluationException>
leftIter
private boolean
leftJoin
private java.util.function.IntFunction<java.util.Map<BindingSetHashKey,java.util.List<BindingSet>>>
mapMaker
private java.util.function.IntFunction<java.util.List<BindingSet>>
mapValueMaker
private CloseableIteration<BindingSet,QueryEvaluationException>
restIter
private CloseableIteration<BindingSet,QueryEvaluationException>
rightIter
private java.util.Iterator<BindingSet>
scanList
-
Constructor Summary
Constructors Constructor Description HashJoinIteration(CloseableIteration<BindingSet,QueryEvaluationException> leftIter, java.util.Set<java.lang.String> leftBindingNames, CloseableIteration<BindingSet,QueryEvaluationException> rightIter, java.util.Set<java.lang.String> rightBindingNames, boolean leftJoin)
HashJoinIteration(CloseableIteration<BindingSet,QueryEvaluationException> leftIter, java.util.Set<java.lang.String> leftBindingNames, CloseableIteration<BindingSet,QueryEvaluationException> rightIter, java.util.Set<java.lang.String> rightBindingNames, boolean leftJoin, java.util.function.IntFunction<java.util.Map<BindingSetHashKey,java.util.List<BindingSet>>> mapMaker, java.util.function.IntFunction<java.util.List<BindingSet>> mapValueMaker)
Deprecated, for removal: This API element is subject to removal in a future version.HashJoinIteration(EvaluationStrategy strategy, Join join, BindingSet bindings)
Deprecated, for removal: This API element is subject to removal in a future version.HashJoinIteration(EvaluationStrategy strategy, LeftJoin join, BindingSet bindings)
Deprecated, for removal: This API element is subject to removal in a future version.HashJoinIteration(EvaluationStrategy strategy, TupleExpr left, TupleExpr right, BindingSet bindings, boolean leftJoin)
HashJoinIteration(QueryEvaluationStep left, QueryEvaluationStep right, BindingSet bindings, boolean leftJoin, java.lang.String[] joinAttributes, QueryEvaluationContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <E> void
add(java.util.Collection<E> col, E value)
protected <E> void
addAll(java.util.Collection<E> col, java.util.List<E> values)
protected <E> void
closeHashValue(java.util.Iterator<E> iter)
Utility methods to clear-up in case not using in-memory hash table.protected void
disposeCache(java.util.Iterator<BindingSet> iter)
Utility methods to clear-up in case not using in-memory cache.protected void
disposeHashTable(java.util.Map<BindingSetHashKey,java.util.List<BindingSet>> map)
Utility methods to clear-up in case not using in-memory hash table.protected BindingSet
getNextElement()
Gets the next element.protected void
handleClose()
Called byAbstractCloseableIteration.close()
when it is called for the first time.static java.lang.String[]
hashJoinAttributeNames(Join join)
static java.lang.String[]
hashJoinAttributeNames(LeftJoin join)
protected java.util.Map<BindingSetHashKey,java.util.List<BindingSet>>
makeHashTable(int initialSize)
Utility methods to make it easier to inserted custom store dependent mapsprotected java.util.List<BindingSet>
makeHashValue(int currentMaxListSize)
Utility methods to make it easier to inserted custom store dependent listprotected java.util.Collection<BindingSet>
makeIterationCache(CloseableIteration<BindingSet,QueryEvaluationException> iter)
Utility methods to make it easier to inserted custom store dependent listprotected <E> E
nextFromCache(java.util.Iterator<E> iter)
protected void
putHashTableEntry(java.util.Map<BindingSetHashKey,java.util.List<BindingSet>> nextHashTable, BindingSetHashKey hashKey, java.util.List<BindingSet> hashValue, boolean newEntry)
private java.util.Map<BindingSetHashKey,java.util.List<BindingSet>>
setupHashTable()
-
Methods inherited from class org.eclipse.rdf4j.common.iteration.LookAheadIteration
hasNext, next, remove
-
Methods inherited from class org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration
close, isClosed
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.common.iteration.CloseableIteration
stream
-
-
-
-
Field Detail
-
joinAttributes
protected final java.lang.String[] joinAttributes
-
leftIter
private final CloseableIteration<BindingSet,QueryEvaluationException> leftIter
-
rightIter
private final CloseableIteration<BindingSet,QueryEvaluationException> rightIter
-
leftJoin
private final boolean leftJoin
-
scanList
private java.util.Iterator<BindingSet> scanList
-
restIter
private CloseableIteration<BindingSet,QueryEvaluationException> restIter
-
hashTable
private java.util.Map<BindingSetHashKey,java.util.List<BindingSet>> hashTable
-
currentScanElem
private BindingSet currentScanElem
-
hashTableValues
private java.util.Iterator<BindingSet> hashTableValues
-
mapMaker
private final java.util.function.IntFunction<java.util.Map<BindingSetHashKey,java.util.List<BindingSet>>> mapMaker
-
mapValueMaker
private final java.util.function.IntFunction<java.util.List<BindingSet>> mapValueMaker
-
bsMaker
private final java.util.function.Function<BindingSet,MutableBindingSet> bsMaker
-
-
Constructor Detail
-
HashJoinIteration
@Deprecated(forRemoval=true) public HashJoinIteration(EvaluationStrategy strategy, Join join, BindingSet bindings) throws QueryEvaluationException
Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
QueryEvaluationException
-
HashJoinIteration
@Deprecated(forRemoval=true) public HashJoinIteration(EvaluationStrategy strategy, LeftJoin join, BindingSet bindings) throws QueryEvaluationException
Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
QueryEvaluationException
-
HashJoinIteration
public HashJoinIteration(EvaluationStrategy strategy, TupleExpr left, TupleExpr right, BindingSet bindings, boolean leftJoin) throws QueryEvaluationException
- Throws:
QueryEvaluationException
-
HashJoinIteration
public HashJoinIteration(QueryEvaluationStep left, QueryEvaluationStep right, BindingSet bindings, boolean leftJoin, java.lang.String[] joinAttributes, QueryEvaluationContext context) throws QueryEvaluationException
- Throws:
QueryEvaluationException
-
HashJoinIteration
public HashJoinIteration(CloseableIteration<BindingSet,QueryEvaluationException> leftIter, java.util.Set<java.lang.String> leftBindingNames, CloseableIteration<BindingSet,QueryEvaluationException> rightIter, java.util.Set<java.lang.String> rightBindingNames, boolean leftJoin) throws QueryEvaluationException
- Throws:
QueryEvaluationException
-
HashJoinIteration
@Deprecated(forRemoval=true) public HashJoinIteration(CloseableIteration<BindingSet,QueryEvaluationException> leftIter, java.util.Set<java.lang.String> leftBindingNames, CloseableIteration<BindingSet,QueryEvaluationException> rightIter, java.util.Set<java.lang.String> rightBindingNames, boolean leftJoin, java.util.function.IntFunction<java.util.Map<BindingSetHashKey,java.util.List<BindingSet>>> mapMaker, java.util.function.IntFunction<java.util.List<BindingSet>> mapValueMaker) throws QueryEvaluationException
Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
QueryEvaluationException
-
-
Method Detail
-
getNextElement
protected BindingSet getNextElement() throws QueryEvaluationException
Description copied from class:LookAheadIteration
Gets the next element. Subclasses should implement this method so that it returns the next element.- Specified by:
getNextElement
in classLookAheadIteration<BindingSet,QueryEvaluationException>
- Returns:
- The next element, or null if no more elements are available.
- Throws:
QueryEvaluationException
-
handleClose
protected void handleClose() throws QueryEvaluationException
Description copied from class:AbstractCloseableIteration
Called byAbstractCloseableIteration.close()
when it is called for the first time. This method is only called once on each iteration. By default, this method does nothing.- Overrides:
handleClose
in classLookAheadIteration<BindingSet,QueryEvaluationException>
- Throws:
QueryEvaluationException
-
setupHashTable
private java.util.Map<BindingSetHashKey,java.util.List<BindingSet>> setupHashTable() throws QueryEvaluationException
- Throws:
QueryEvaluationException
-
putHashTableEntry
protected void putHashTableEntry(java.util.Map<BindingSetHashKey,java.util.List<BindingSet>> nextHashTable, BindingSetHashKey hashKey, java.util.List<BindingSet> hashValue, boolean newEntry) throws QueryEvaluationException
- Throws:
QueryEvaluationException
-
makeIterationCache
protected java.util.Collection<BindingSet> makeIterationCache(CloseableIteration<BindingSet,QueryEvaluationException> iter)
Utility methods to make it easier to inserted custom store dependent list- Returns:
- list
-
makeHashTable
protected java.util.Map<BindingSetHashKey,java.util.List<BindingSet>> makeHashTable(int initialSize)
Utility methods to make it easier to inserted custom store dependent maps- Returns:
- map
-
makeHashValue
protected java.util.List<BindingSet> makeHashValue(int currentMaxListSize)
Utility methods to make it easier to inserted custom store dependent list- Returns:
- list
-
disposeCache
protected void disposeCache(java.util.Iterator<BindingSet> iter)
Utility methods to clear-up in case not using in-memory cache.
-
disposeHashTable
protected void disposeHashTable(java.util.Map<BindingSetHashKey,java.util.List<BindingSet>> map)
Utility methods to clear-up in case not using in-memory hash table.
-
closeHashValue
protected <E> void closeHashValue(java.util.Iterator<E> iter)
Utility methods to clear-up in case not using in-memory hash table.
-
nextFromCache
protected <E> E nextFromCache(java.util.Iterator<E> iter)
-
add
protected <E> void add(java.util.Collection<E> col, E value) throws QueryEvaluationException
- Throws:
QueryEvaluationException
-
addAll
protected <E> void addAll(java.util.Collection<E> col, java.util.List<E> values) throws QueryEvaluationException
- Throws:
QueryEvaluationException
-
hashJoinAttributeNames
public static java.lang.String[] hashJoinAttributeNames(Join join)
-
hashJoinAttributeNames
public static java.lang.String[] hashJoinAttributeNames(LeftJoin join)
-
-