Skip to content

Commit

Permalink
Merge pull request #234 from usethesource/satisfy-cf
Browse files Browse the repository at this point in the history
Adding CF annotations to resurrected classes for transitive closure optimization
  • Loading branch information
jurgenvinju authored Jan 9, 2024
2 parents 6f3728c + ac77a7e commit 1265053
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 797 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -557,7 +556,7 @@ public ISet closure() {
@Override
public ISet closureStar() {
// calculate
java.util.Set<IValue> closureDelta = computeClosureDelta();
ShareableValuesHashSet closureDelta = computeClosureDelta();

IWriter<ISet> resultWriter = writer();
resultWriter.insertAll(this);
Expand All @@ -570,21 +569,21 @@ public ISet closureStar() {
return resultWriter.done();
}

private java.util.Set<IValue> computeClosureDelta() {
private ShareableValuesHashSet computeClosureDelta() {
IValueFactory vf = ValueFactory.getInstance();
RotatingQueue<IValue> iLeftKeys = new RotatingQueue<>();
RotatingQueue<RotatingQueue<IValue>> iLefts = new RotatingQueue<>();

Map<IValue, RotatingQueue<IValue>> interestingLeftSides = new HashMap<>();
Map<IValue, java.util.Set<IValue>> potentialRightSides = new HashMap<>();
Map<IValue, ShareableValuesHashSet> potentialRightSides = new HashMap<>();

// Index
for (IValue val : this) {
ITuple tuple = (ITuple) val;
IValue key = tuple.get(0);
IValue value = tuple.get(1);
RotatingQueue<IValue> leftValues = interestingLeftSides.get(key);
java.util.Set<IValue> rightValues;
ShareableValuesHashSet rightValues;

if (leftValues != null) {
rightValues = potentialRightSides.get(key);
Expand All @@ -610,9 +609,9 @@ private java.util.Set<IValue> computeClosureDelta() {
int nextSize = 0;

// Compute
final java.util.Set<IValue> newTuples = new ShareableValuesHashSet();
final ShareableValuesHashSet newTuples = new ShareableValuesHashSet();
do {
Map<IValue, java.util.Set<IValue>> rightSides = potentialRightSides;
Map<IValue, ShareableValuesHashSet> rightSides = potentialRightSides;
potentialRightSides = new HashMap<>();

for (; size > 0; size--) {
Expand All @@ -625,7 +624,7 @@ private java.util.Set<IValue> computeClosureDelta() {

IValue rightKey;
while ((rightKey = leftValues.get()) != null) {
java.util.Set<IValue> rightValues = rightSides.get(rightKey);
ShareableValuesHashSet rightValues = rightSides.get(rightKey);
if (rightValues != null) {
Iterator<IValue> rightValuesIterator = rightValues.iterator();
while (rightValuesIterator.hasNext()) {
Expand All @@ -640,9 +639,9 @@ private java.util.Set<IValue> computeClosureDelta() {
}
interestingLeftValues.put(rightValue);

java.util.Set<IValue> potentialRightValues = potentialRightSides.get(rightKey);
ShareableValuesHashSet potentialRightValues = potentialRightSides.get(rightKey);
if (potentialRightValues == null) {
potentialRightValues = new HashSet<>();
potentialRightValues = new ShareableValuesHashSet();
potentialRightSides.put(rightKey, potentialRightValues);
}
potentialRightValues.add(rightValue);
Expand Down
Loading

0 comments on commit 1265053

Please sign in to comment.