Skip to content

Commit

Permalink
GH-4899 Use the collection factory provided sets and queues in path
Browse files Browse the repository at this point in the history
iterations
  • Loading branch information
JervenBolleman committed Feb 6, 2024
1 parent 85dcb36 commit 466d694
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ public <T> Set<T> createSet() {
if (iterationCacheSyncThreshold > 0) {
init();
Serializer<T> serializer = createAnySerializer();
MemoryTillSizeXSet<T> set = new MemoryTillSizeXSet<T>(colectionId++, delegate.createSet(), serializer,
MemoryTillSizeXSet<T> set = new MemoryTillSizeXSet<>(colectionId++, delegate.createSet(), serializer,
DEFAULT_SWITCH_TO_DISK_BASED_SET_AT_SIZE);
return new CommitingSet<T>(set, iterationCacheSyncThreshold, db);
return new CommitingSet<>(set, iterationCacheSyncThreshold, db);
} else {
return delegate.createSet();
}
Expand All @@ -199,7 +199,7 @@ public Set<Value> createValueSet() {
Serializer<Value> serializer = createValueSerializer();
Set<Value> set = new MemoryTillSizeXSet<>(colectionId++, delegate.createValueSet(), serializer,
DEFAULT_SWITCH_TO_DISK_BASED_SET_AT_SIZE);
return new CommitingSet<Value>(set, iterationCacheSyncThreshold, db);
return new CommitingSet<>(set, iterationCacheSyncThreshold, db);
} else {
return delegate.createValueSet();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Queue;
import java.util.Set;

import org.eclipse.rdf4j.collection.factory.api.CollectionFactory;
import org.eclipse.rdf4j.common.iteration.CloseableIteration;
import org.eclipse.rdf4j.common.iteration.LookAheadIteration;
import org.eclipse.rdf4j.model.Value;
Expand Down Expand Up @@ -68,6 +69,8 @@ public class PathIteration extends LookAheadIteration<BindingSet> {

private final Set<String> namedIntermediateJoins = new HashSet<>();

private final CollectionFactory collectionFactory;

public PathIteration(EvaluationStrategy strategy, Scope scope, Var startVar,
TupleExpr pathExpression, Var endVar, Var contextVar, long minLength, BindingSet bindings)
throws QueryEvaluationException {
Expand All @@ -85,9 +88,10 @@ public PathIteration(EvaluationStrategy strategy, Scope scope, Var startVar,
this.currentLength = minLength;
this.bindings = bindings;

this.reportedValues = strategy.makeSet();
this.unreportedValues = strategy.makeSet();
this.valueQueue = strategy.makeQueue();
collectionFactory = strategy.getCollectionFactory().get();
this.reportedValues = collectionFactory.createSet();
this.unreportedValues = collectionFactory.createSet();
this.valueQueue = collectionFactory.createQueue();

createIteration();
}
Expand Down Expand Up @@ -218,7 +222,7 @@ protected void handleClose() throws QueryEvaluationException {
if (currentIter != null) {
currentIter.close();
}

collectionFactory.close();
}

/**
Expand Down

0 comments on commit 466d694

Please sign in to comment.