diff options
author | 2023-03-01 02:15:50 +0100 | |
---|---|---|
committer | 2023-03-01 11:10:39 +0100 | |
commit | da5d898b3bad6f55efd6619f0abee0ec8aa1de4b (patch) | |
tree | d752bb975189a52aaaa5211e64dec42ea0b152fe /subprojects/store-query-viatra/src/test | |
parent | chore(deps): bump dependencies (diff) | |
download | refinery-da5d898b3bad6f55efd6619f0abee0ec8aa1de4b.tar.gz refinery-da5d898b3bad6f55efd6619f0abee0ec8aa1de4b.tar.zst refinery-da5d898b3bad6f55efd6619f0abee0ec8aa1de4b.zip |
refactor: more direct access to VIATRA result set
Accessing VIATRA result sets through IQueryResultProvider requires a lot
of indirection, allocations, and locking.
We use reflection instead to have direct access to the underlying
Indexer instead.
Unfortunately, projection to arbitrary tuple masks (with wildcard
entries in a tuple) is completely broken in VIATRA when RETE update
propagation is delayed. While a new, ad-hoc projection indexer gets
added to the RETE net immediately, it is not populated with the
projection results until updates are flushed in the query engine.
Therefore, when encountering an ad-hoc projection for the first time,
the projection results will always be empty (thus usually out of date).
While declaring the desired projections ahead of time would be a
possible solution, for now, we completely remove ad-hoc projection
support. If projections are needed on the ModelQuery level, we should
create an API for declaring projections for each registered Dnf.
Diffstat (limited to 'subprojects/store-query-viatra/src/test')
-rw-r--r-- | subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java index 54ae70c3..3dd517c4 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java | |||
@@ -16,8 +16,7 @@ import java.util.HashSet; | |||
16 | import java.util.Set; | 16 | import java.util.Set; |
17 | import java.util.stream.Stream; | 17 | import java.util.stream.Stream; |
18 | 18 | ||
19 | import static org.junit.jupiter.api.Assertions.assertEquals; | 19 | import static org.junit.jupiter.api.Assertions.*; |
20 | import static org.junit.jupiter.api.Assertions.assertThrows; | ||
21 | import static tools.refinery.store.query.literal.Literals.not; | 20 | import static tools.refinery.store.query.literal.Literals.not; |
22 | 21 | ||
23 | class QueryTest { | 22 | class QueryTest { |
@@ -97,10 +96,14 @@ class QueryTest { | |||
97 | friendInterpretation.put(Tuple.of(1, 2), TruthValue.TRUE); | 96 | friendInterpretation.put(Tuple.of(1, 2), TruthValue.TRUE); |
98 | 97 | ||
99 | assertEquals(0, predicateResultSet.countResults()); | 98 | assertEquals(0, predicateResultSet.countResults()); |
99 | assertFalse(predicateResultSet.hasResult(Tuple.of(0, 1))); | ||
100 | assertFalse(predicateResultSet.hasResult(Tuple.of(0, 2))); | ||
100 | 101 | ||
101 | queryEngine.flushChanges(); | 102 | queryEngine.flushChanges(); |
102 | assertEquals(3, predicateResultSet.countResults()); | 103 | assertEquals(3, predicateResultSet.countResults()); |
103 | compareMatchSets(predicateResultSet.allResults(), Set.of(Tuple.of(0, 1), Tuple.of(1, 0), Tuple.of(1, 2))); | 104 | compareMatchSets(predicateResultSet.allResults(), Set.of(Tuple.of(0, 1), Tuple.of(1, 0), Tuple.of(1, 2))); |
105 | assertTrue(predicateResultSet.hasResult(Tuple.of(0, 1))); | ||
106 | assertFalse(predicateResultSet.hasResult(Tuple.of(0, 2))); | ||
104 | } | 107 | } |
105 | 108 | ||
106 | @Test | 109 | @Test |