From c7a86623b1589a3bd68a84a8d54a1eadc1aacefb Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 10 Sep 2023 23:07:11 +0200 Subject: fix: VIATRA projection indexer error When a projection indexer is constructed for a production node, the projection memory is only populated if changes are being propagated. The cache doesn't get populated even if changes are flushed afterwards. This not only returns invalid query results, but also a duplicate deletion exception will be thrown when the production node tries to delete a tuple from the index memory. To counteract this issue, we enable update propagation while a matcher (and its associated indexers) are being created. --- .../store/query/viatra/internal/pquery/TermEvaluator.java | 4 ++-- .../viatra/internal/update/TupleChangingViewUpdateListener.java | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'subprojects/store-query-viatra') diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java index 5df861a6..d064ff2c 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java @@ -5,10 +5,10 @@ */ package tools.refinery.store.query.viatra.internal.pquery; -import tools.refinery.viatra.runtime.matchers.psystem.IExpressionEvaluator; -import tools.refinery.viatra.runtime.matchers.psystem.IValueProvider; import tools.refinery.store.query.term.Term; import tools.refinery.store.query.term.Variable; +import tools.refinery.viatra.runtime.matchers.psystem.IExpressionEvaluator; +import tools.refinery.viatra.runtime.matchers.psystem.IValueProvider; import java.util.stream.Collectors; diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingViewUpdateListener.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingViewUpdateListener.java index 9dc739f1..5577faa3 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingViewUpdateListener.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingViewUpdateListener.java @@ -5,11 +5,11 @@ */ package tools.refinery.store.query.viatra.internal.update; -import tools.refinery.viatra.runtime.matchers.tuple.Tuples; import tools.refinery.store.model.Interpretation; import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; import tools.refinery.store.query.view.SymbolView; import tools.refinery.store.tuple.Tuple; +import tools.refinery.viatra.runtime.matchers.tuple.Tuples; import java.util.Arrays; @@ -27,18 +27,19 @@ public class TupleChangingViewUpdateListener extends SymbolViewUpdateListener boolean fromPresent = view.filter(key, fromValue); boolean toPresent = view.filter(key, toValue); if (fromPresent) { + var fromArray = view.forwardMap(key, fromValue); if (toPresent) { // value change - var fromArray = view.forwardMap(key, fromValue); var toArray = view.forwardMap(key, toValue); if (!Arrays.equals(fromArray, toArray)) { processUpdate(Tuples.flatTupleOf(fromArray), false); processUpdate(Tuples.flatTupleOf(toArray), true); } } else { // fromValue disappears - processUpdate(Tuples.flatTupleOf(view.forwardMap(key, fromValue)), false); + processUpdate(Tuples.flatTupleOf(fromArray), false); } } else if (toPresent) { // toValue appears - processUpdate(Tuples.flatTupleOf(view.forwardMap(key, toValue)), true); + var toArray = view.forwardMap(key, toValue); + processUpdate(Tuples.flatTupleOf(toArray), true); } } } -- cgit v1.2.3-70-g09d2