Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public final class RecordAndReplayPropagator<Tuple_ extends AbstractTuple>
private final Supplier<BavetPrecomputeBuildHelper<Tuple_>> precomputeBuildHelperSupplier;
private final UnaryOperator<Tuple_> internalTupleToOutputTupleMapper;
private final Map<Object, List<Tuple_>> objectToOutputTuplesMap;
private final Set<Object> alreadyUpdatingMap = Collections.newSetFromMap(new IdentityHashMap<>());
private final Map<Class<?>, Boolean> objectClassToIsEntitySourceClass;

private final StaticPropagationQueue<Tuple_> propagationQueue;
Expand Down Expand Up @@ -77,14 +78,18 @@ public void insert(Object object) {
}

public void update(Object object) {
if (!alreadyUpdatingMap.add(object)) {
// The list was already sent to the propagation queue.
// Don't iterate over it again, even though the queue would deduplicate its contents.
return;
}
// Updates happen very frequently, so we optimize by avoiding the update queue
// and going straight to the propagation queue.
// The propagation queue deduplicates updates internally.
var outTupleList = objectToOutputTuplesMap.get(object);
if (outTupleList == null) {
return;
if (outTupleList != null) {
outTupleList.forEach(propagationQueue::update);
}
outTupleList.forEach(propagationQueue::update);
}

public void retract(Object object) {
Expand Down Expand Up @@ -158,6 +163,7 @@ private static <A> List<BavetRootNode<A>> getRootNodes(Object object, NodeNetwor
@Override
public void propagateUpdates() {
propagationQueue.propagateUpdates();
alreadyUpdatingMap.clear();
}

@Override
Expand Down Expand Up @@ -207,7 +213,7 @@ private void recalculateTuples(NodeNetwork internalNodeNetwork,
internalNodeNetwork.settle();
}
if (mappedTuples.isEmpty()) {
objectToOutputTuplesMap.put(invalidated, Collections.emptyList());
objectToOutputTuplesMap.remove(invalidated);
} else {
objectToOutputTuplesMap.put(invalidated, mappedTuples);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ public <Key_> Key_ get(int id) {

@Override
public int hashCode() {
var hash = 7;
hash = 31 * hash + Objects.hashCode(propertyA);
hash = 31 * hash + Objects.hashCode(propertyB);
return hash;
return 31 * Objects.hashCode(propertyA) + Objects.hashCode(propertyB);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
var hash = 7;
hash = 31 * hash + Objects.hashCode(from);
var hash = Objects.hashCode(from);
hash = 31 * hash + Objects.hashCode(to);
hash = 31 * hash + Objects.hashCode(incrementUnit);
return hash;
return 31 * hash + Objects.hashCode(incrementUnit);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,9 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
var hash = 7;
hash = 31 * hash + Objects.hashCode(from);
var hash = Objects.hashCode(from);
hash = 31 * hash + Objects.hashCode(to);
hash = 31 * hash + Objects.hashCode(incrementUnit);
return hash;
return 31 * hash + Objects.hashCode(incrementUnit);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
var hash = 7;
hash = 31 * hash + Boolean.hashCode(isValueImmutable);
hash = 31 * hash + Objects.hashCode(list);
return hash;
return 31 * Boolean.hashCode(isValueImmutable) + Objects.hashCode(list);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
var hash = 7;
hash = 31 * hash + Boolean.hashCode(isValueImmutable);
hash = 31 * hash + Objects.hashCode(set);
return hash;
return 31 * Boolean.hashCode(isValueImmutable) + Objects.hashCode(set);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
var hash = 7;
hash = 31 * hash + Boolean.hashCode(isValueImmutable);
hash = 31 * hash + Objects.hashCode(valueRangeList);
return hash;
return 31 * Boolean.hashCode(isValueImmutable) + Objects.hashCode(valueRangeList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
var hash = 7;
hash = 31 * hash + Double.hashCode(from);
hash = 31 * hash + Double.hashCode(to);
return hash;
return 31 * Double.hashCode(from) + Double.hashCode(to);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,9 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
var hash = 7;
hash = 31 * hash + Integer.hashCode(from);
var hash = Integer.hashCode(from);
hash = 31 * hash + Integer.hashCode(to);
hash = 31 * hash + Integer.hashCode(incrementUnit);
return hash;
return 31 * hash + Integer.hashCode(incrementUnit);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,9 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
var hash = 7;
hash = 31 * hash + Long.hashCode(from);
var hash = Long.hashCode(from);
hash = 31 * hash + Long.hashCode(to);
hash = 31 * hash + Long.hashCode(incrementUnit);
return hash;
return 31 * hash + Long.hashCode(incrementUnit);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,10 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
var hash = 7;
hash = 31 * hash + Long.hashCode(incrementUnitAmount);
var hash = Long.hashCode(incrementUnitAmount);
hash = 31 * hash + Objects.hashCode(incrementUnitType);
hash = 31 * hash + Objects.hashCode(from);
hash = 31 * hash + Objects.hashCode(to);
return hash;
return 31 * hash + Objects.hashCode(to);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ public record Pair<Key_, Value_>(Key_ key, Value_ value) {

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
return o instanceof Pair<?, ?> other
&& Objects.equals(key, other.key)
&& Objects.equals(value, other.value);
}

@Override
public int hashCode() { // Often used in hash-based collections; the JDK-generated default is too slow.
var hash = 7;
hash = 31 * hash + Objects.hashCode(key);
hash = 31 * hash + Objects.hashCode(value);
return hash;
return 31 * Objects.hashCode(key) + Objects.hashCode(value);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public record Quadruple<A, B, C, D>(A a, B b, C c, D d) {

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
return o instanceof Quadruple<?, ?, ?, ?> other
&& Objects.equals(a, other.a)
&& Objects.equals(b, other.b)
Expand All @@ -25,12 +28,10 @@ public boolean equals(Object o) {

@Override
public int hashCode() { // Often used in hash-based collections; the JDK-generated default is too slow.
var hash = 7;
hash = 31 * hash + Objects.hashCode(a);
var hash = Objects.hashCode(a);
hash = 31 * hash + Objects.hashCode(b);
hash = 31 * hash + Objects.hashCode(c);
hash = 31 * hash + Objects.hashCode(d);
return hash;
return 31 * hash + Objects.hashCode(d);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public record Triple<A, B, C>(A a, B b, C c) {

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
return o instanceof Triple<?, ?, ?> other
&& Objects.equals(a, other.a)
&& Objects.equals(b, other.b)
Expand All @@ -23,11 +26,9 @@ public boolean equals(Object o) {

@Override
public int hashCode() { // Often used in hash-based collections; the JDK-generated default is too slow.
var hash = 7;
hash = 31 * hash + Objects.hashCode(a);
var hash = Objects.hashCode(a);
hash = 31 * hash + Objects.hashCode(b);
hash = 31 * hash + Objects.hashCode(c);
return hash;
return 31 * hash + Objects.hashCode(c);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ public TestdataObjectEquals(Integer id) {

@Override
public int hashCode() {
int hash = 5;
hash = 37 * hash + Objects.hashCode(this.id);
return hash;
return Objects.hashCode(this.id);
}

@Override
Expand Down
Loading