summaryrefslogtreecommitdiffstats
path: root/subprojects/store-query-viatra
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2023-09-10 23:07:11 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2023-09-10 23:07:11 +0200
commitc7a86623b1589a3bd68a84a8d54a1eadc1aacefb (patch)
tree16fb5eb3d3b1282fecedefd9c7ae519162c540da /subprojects/store-query-viatra
parentfeat: integrate DSE with partial interpretation (diff)
downloadrefinery-c7a86623b1589a3bd68a84a8d54a1eadc1aacefb.tar.gz
refinery-c7a86623b1589a3bd68a84a8d54a1eadc1aacefb.tar.zst
refinery-c7a86623b1589a3bd68a84a8d54a1eadc1aacefb.zip
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.
Diffstat (limited to 'subprojects/store-query-viatra')
-rw-r--r--subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java4
-rw-r--r--subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingViewUpdateListener.java9
2 files changed, 7 insertions, 6 deletions
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 @@
5 */ 5 */
6package tools.refinery.store.query.viatra.internal.pquery; 6package tools.refinery.store.query.viatra.internal.pquery;
7 7
8import tools.refinery.viatra.runtime.matchers.psystem.IExpressionEvaluator;
9import tools.refinery.viatra.runtime.matchers.psystem.IValueProvider;
10import tools.refinery.store.query.term.Term; 8import tools.refinery.store.query.term.Term;
11import tools.refinery.store.query.term.Variable; 9import tools.refinery.store.query.term.Variable;
10import tools.refinery.viatra.runtime.matchers.psystem.IExpressionEvaluator;
11import tools.refinery.viatra.runtime.matchers.psystem.IValueProvider;
12 12
13import java.util.stream.Collectors; 13import java.util.stream.Collectors;
14 14
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 @@
5 */ 5 */
6package tools.refinery.store.query.viatra.internal.update; 6package tools.refinery.store.query.viatra.internal.update;
7 7
8import tools.refinery.viatra.runtime.matchers.tuple.Tuples;
9import tools.refinery.store.model.Interpretation; 8import tools.refinery.store.model.Interpretation;
10import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; 9import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl;
11import tools.refinery.store.query.view.SymbolView; 10import tools.refinery.store.query.view.SymbolView;
12import tools.refinery.store.tuple.Tuple; 11import tools.refinery.store.tuple.Tuple;
12import tools.refinery.viatra.runtime.matchers.tuple.Tuples;
13 13
14import java.util.Arrays; 14import java.util.Arrays;
15 15
@@ -27,18 +27,19 @@ public class TupleChangingViewUpdateListener<T> extends SymbolViewUpdateListener
27 boolean fromPresent = view.filter(key, fromValue); 27 boolean fromPresent = view.filter(key, fromValue);
28 boolean toPresent = view.filter(key, toValue); 28 boolean toPresent = view.filter(key, toValue);
29 if (fromPresent) { 29 if (fromPresent) {
30 var fromArray = view.forwardMap(key, fromValue);
30 if (toPresent) { // value change 31 if (toPresent) { // value change
31 var fromArray = view.forwardMap(key, fromValue);
32 var toArray = view.forwardMap(key, toValue); 32 var toArray = view.forwardMap(key, toValue);
33 if (!Arrays.equals(fromArray, toArray)) { 33 if (!Arrays.equals(fromArray, toArray)) {
34 processUpdate(Tuples.flatTupleOf(fromArray), false); 34 processUpdate(Tuples.flatTupleOf(fromArray), false);
35 processUpdate(Tuples.flatTupleOf(toArray), true); 35 processUpdate(Tuples.flatTupleOf(toArray), true);
36 } 36 }
37 } else { // fromValue disappears 37 } else { // fromValue disappears
38 processUpdate(Tuples.flatTupleOf(view.forwardMap(key, fromValue)), false); 38 processUpdate(Tuples.flatTupleOf(fromArray), false);
39 } 39 }
40 } else if (toPresent) { // toValue appears 40 } else if (toPresent) { // toValue appears
41 processUpdate(Tuples.flatTupleOf(view.forwardMap(key, toValue)), true); 41 var toArray = view.forwardMap(key, toValue);
42 processUpdate(Tuples.flatTupleOf(toArray), true);
42 } 43 }
43 } 44 }
44} 45}