Skip to content

Commit

Permalink
Merge pull request #232 from usethesource/re-introduce-shareable-valu…
Browse files Browse the repository at this point in the history
…es-hash-sets

re introduce shareable values hash sets
  • Loading branch information
jurgenvinju authored Jan 8, 2024
2 parents a5dfefc + c6d5900 commit 2047d32
Show file tree
Hide file tree
Showing 4 changed files with 1,141 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import io.usethesource.vallang.IValue;
import io.usethesource.vallang.IValueFactory;
import io.usethesource.vallang.IWriter;
import io.usethesource.vallang.impl.util.collections.ShareableValuesHashSet;
import io.usethesource.vallang.type.Type;
import io.usethesource.vallang.util.AbstractTypeBag;
import io.usethesource.vallang.util.RotatingQueue;
Expand Down Expand Up @@ -593,13 +594,13 @@ private java.util.Set<IValue> computeClosureDelta() {
iLefts.put(leftValues);
interestingLeftSides.put(key, leftValues);

rightValues = new HashSet<>();
rightValues = new ShareableValuesHashSet();
potentialRightSides.put(key, rightValues);
}

leftValues.put(value);
if (rightValues == null) {
rightValues = new HashSet<>();
rightValues = new ShareableValuesHashSet();
}

rightValues.add(value);
Expand All @@ -609,7 +610,7 @@ private java.util.Set<IValue> computeClosureDelta() {
int nextSize = 0;

// Compute
final java.util.Set<IValue> newTuples = new HashSet<>();
final java.util.Set<IValue> newTuples = new ShareableValuesHashSet();
do {
Map<IValue, java.util.Set<IValue>> rightSides = potentialRightSides;
potentialRightSides = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ public boolean equals(@Nullable Object o) {
if (o.getClass() == getClass()) {
Tuple otherTuple = (Tuple) o;

if (getType() != otherTuple.getType()) {
return false;
// checking for the type will dynamically allocate memory
// because tuple types are computed lazily.
// so we skip this "fast failure" check
// if (getType() != otherTuple.getType()) { return false; }

}

IValue[] otherElements = otherTuple.elements;
int nrOfElements = elements.length;
Expand Down
Loading

0 comments on commit 2047d32

Please sign in to comment.