diff options
Diffstat (limited to 'subprojects/store-query-viatra/src/main/java')
11 files changed, 105 insertions, 105 deletions
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java index 999d349a..44ed1505 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java | |||
@@ -117,7 +117,7 @@ public class ViatraModelQueryBuilderImpl extends AbstractModelAdapterBuilder imp | |||
117 | public ViatraModelQueryStoreAdapterImpl createStoreAdapter(ModelStore store) { | 117 | public ViatraModelQueryStoreAdapterImpl createStoreAdapter(ModelStore store) { |
118 | validateSymbols(store); | 118 | validateSymbols(store); |
119 | dnf2PQuery.assertNoUnusedHints(); | 119 | dnf2PQuery.assertNoUnusedHints(); |
120 | return new ViatraModelQueryStoreAdapterImpl(store, buildEngineOptions(), dnf2PQuery.getRelationViews(), | 120 | return new ViatraModelQueryStoreAdapterImpl(store, buildEngineOptions(), dnf2PQuery.getSymbolViews(), |
121 | Collections.unmodifiableMap(querySpecifications), Collections.unmodifiableSet(vacuousQueries)); | 121 | Collections.unmodifiableMap(querySpecifications), Collections.unmodifiableSet(vacuousQueries)); |
122 | } | 122 | } |
123 | 123 | ||
@@ -140,11 +140,11 @@ public class ViatraModelQueryBuilderImpl extends AbstractModelAdapterBuilder imp | |||
140 | 140 | ||
141 | private void validateSymbols(ModelStore store) { | 141 | private void validateSymbols(ModelStore store) { |
142 | var symbols = store.getSymbols(); | 142 | var symbols = store.getSymbols(); |
143 | for (var relationView : dnf2PQuery.getRelationViews().keySet()) { | 143 | for (var symbolView : dnf2PQuery.getSymbolViews().keySet()) { |
144 | var symbol = relationView.getSymbol(); | 144 | var symbol = symbolView.getSymbol(); |
145 | if (!symbols.contains(symbol)) { | 145 | if (!symbols.contains(symbol)) { |
146 | throw new IllegalArgumentException("Cannot query relation view %s: symbol %s is not in the model" | 146 | throw new IllegalArgumentException("Cannot query view %s: symbol %s is not in the model" |
147 | .formatted(relationView, symbol)); | 147 | .formatted(symbolView, symbol)); |
148 | } | 148 | } |
149 | } | 149 | } |
150 | } | 150 | } |
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryStoreAdapterImpl.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryStoreAdapterImpl.java index aa102a35..11a3c7fd 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryStoreAdapterImpl.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryStoreAdapterImpl.java | |||
@@ -13,20 +13,20 @@ import tools.refinery.store.model.ModelStore; | |||
13 | import tools.refinery.store.query.dnf.AnyQuery; | 13 | import tools.refinery.store.query.dnf.AnyQuery; |
14 | import tools.refinery.store.query.viatra.ViatraModelQueryStoreAdapter; | 14 | import tools.refinery.store.query.viatra.ViatraModelQueryStoreAdapter; |
15 | import tools.refinery.store.query.viatra.internal.matcher.RawPatternMatcher; | 15 | import tools.refinery.store.query.viatra.internal.matcher.RawPatternMatcher; |
16 | import tools.refinery.store.query.view.AnyRelationView; | 16 | import tools.refinery.store.query.view.AnySymbolView; |
17 | 17 | ||
18 | import java.util.*; | 18 | import java.util.*; |
19 | 19 | ||
20 | public class ViatraModelQueryStoreAdapterImpl implements ViatraModelQueryStoreAdapter { | 20 | public class ViatraModelQueryStoreAdapterImpl implements ViatraModelQueryStoreAdapter { |
21 | private final ModelStore store; | 21 | private final ModelStore store; |
22 | private final ViatraQueryEngineOptions engineOptions; | 22 | private final ViatraQueryEngineOptions engineOptions; |
23 | private final Map<AnyRelationView, IInputKey> inputKeys; | 23 | private final Map<AnySymbolView, IInputKey> inputKeys; |
24 | private final Map<AnyQuery, IQuerySpecification<RawPatternMatcher>> querySpecifications; | 24 | private final Map<AnyQuery, IQuerySpecification<RawPatternMatcher>> querySpecifications; |
25 | private final Set<AnyQuery> vacuousQueries; | 25 | private final Set<AnyQuery> vacuousQueries; |
26 | private final Set<AnyQuery> allQueries; | 26 | private final Set<AnyQuery> allQueries; |
27 | 27 | ||
28 | ViatraModelQueryStoreAdapterImpl(ModelStore store, ViatraQueryEngineOptions engineOptions, | 28 | ViatraModelQueryStoreAdapterImpl(ModelStore store, ViatraQueryEngineOptions engineOptions, |
29 | Map<AnyRelationView, IInputKey> inputKeys, | 29 | Map<AnySymbolView, IInputKey> inputKeys, |
30 | Map<AnyQuery, IQuerySpecification<RawPatternMatcher>> querySpecifications, | 30 | Map<AnyQuery, IQuerySpecification<RawPatternMatcher>> querySpecifications, |
31 | Set<AnyQuery> vacuousQueries) { | 31 | Set<AnyQuery> vacuousQueries) { |
32 | this.store = store; | 32 | this.store = store; |
@@ -45,11 +45,11 @@ public class ViatraModelQueryStoreAdapterImpl implements ViatraModelQueryStoreAd | |||
45 | return store; | 45 | return store; |
46 | } | 46 | } |
47 | 47 | ||
48 | public Collection<AnyRelationView> getRelationViews() { | 48 | public Collection<AnySymbolView> getSymbolViews() { |
49 | return inputKeys.keySet(); | 49 | return inputKeys.keySet(); |
50 | } | 50 | } |
51 | 51 | ||
52 | public Map<AnyRelationView, IInputKey> getInputKeys() { | 52 | public Map<AnySymbolView, IInputKey> getInputKeys() { |
53 | return inputKeys; | 53 | return inputKeys; |
54 | } | 54 | } |
55 | 55 | ||
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalQueryMetaContext.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalQueryMetaContext.java index 07a5a6ea..cf96b7fd 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalQueryMetaContext.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalQueryMetaContext.java | |||
@@ -10,8 +10,8 @@ import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; | |||
10 | import org.eclipse.viatra.query.runtime.matchers.context.InputKeyImplication; | 10 | import org.eclipse.viatra.query.runtime.matchers.context.InputKeyImplication; |
11 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; | 11 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; |
12 | import tools.refinery.store.query.term.DataSort; | 12 | import tools.refinery.store.query.term.DataSort; |
13 | import tools.refinery.store.query.viatra.internal.pquery.RelationViewWrapper; | 13 | import tools.refinery.store.query.viatra.internal.pquery.SymbolViewWrapper; |
14 | import tools.refinery.store.query.view.AnyRelationView; | 14 | import tools.refinery.store.query.view.AnySymbolView; |
15 | 15 | ||
16 | import java.util.*; | 16 | import java.util.*; |
17 | 17 | ||
@@ -19,9 +19,9 @@ import java.util.*; | |||
19 | * The meta context information for String scopes. | 19 | * The meta context information for String scopes. |
20 | */ | 20 | */ |
21 | public class RelationalQueryMetaContext extends AbstractQueryMetaContext { | 21 | public class RelationalQueryMetaContext extends AbstractQueryMetaContext { |
22 | private final Map<AnyRelationView, IInputKey> inputKeys; | 22 | private final Map<AnySymbolView, IInputKey> inputKeys; |
23 | 23 | ||
24 | RelationalQueryMetaContext(Map<AnyRelationView, IInputKey> inputKeys) { | 24 | RelationalQueryMetaContext(Map<AnySymbolView, IInputKey> inputKeys) { |
25 | this.inputKeys = inputKeys; | 25 | this.inputKeys = inputKeys; |
26 | } | 26 | } |
27 | 27 | ||
@@ -47,23 +47,23 @@ public class RelationalQueryMetaContext extends AbstractQueryMetaContext { | |||
47 | if (implyingKey instanceof JavaTransitiveInstancesKey) { | 47 | if (implyingKey instanceof JavaTransitiveInstancesKey) { |
48 | return List.of(); | 48 | return List.of(); |
49 | } | 49 | } |
50 | var relationView = checkKey(implyingKey); | 50 | var symbolView = checkKey(implyingKey); |
51 | var relationViewImplications = relationView.getImpliedRelationViews(); | 51 | var relationViewImplications = symbolView.getImpliedRelationViews(); |
52 | var inputKeyImplications = new HashSet<InputKeyImplication>(relationViewImplications.size()); | 52 | var inputKeyImplications = new HashSet<InputKeyImplication>(relationViewImplications.size()); |
53 | for (var relationViewImplication : relationViewImplications) { | 53 | for (var relationViewImplication : relationViewImplications) { |
54 | if (!relationView.equals(relationViewImplication.implyingRelationView())) { | 54 | if (!symbolView.equals(relationViewImplication.implyingView())) { |
55 | throw new IllegalArgumentException("Relation view %s returned unrelated implication %s".formatted( | 55 | throw new IllegalArgumentException("Relation view %s returned unrelated implication %s".formatted( |
56 | relationView, relationViewImplication)); | 56 | symbolView, relationViewImplication)); |
57 | } | 57 | } |
58 | var impliedInputKey = inputKeys.get(relationViewImplication.impliedRelationView()); | 58 | var impliedInputKey = inputKeys.get(relationViewImplication.impliedView()); |
59 | // Ignore implications not relevant for any queries included in the model. | 59 | // Ignore implications not relevant for any queries included in the model. |
60 | if (impliedInputKey != null) { | 60 | if (impliedInputKey != null) { |
61 | inputKeyImplications.add(new InputKeyImplication(implyingKey, impliedInputKey, | 61 | inputKeyImplications.add(new InputKeyImplication(implyingKey, impliedInputKey, |
62 | relationViewImplication.impliedIndices())); | 62 | relationViewImplication.impliedIndices())); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | var sorts = relationView.getSorts(); | 65 | var sorts = symbolView.getSorts(); |
66 | int arity = relationView.arity(); | 66 | int arity = symbolView.arity(); |
67 | for (int i = 0; i < arity; i++) { | 67 | for (int i = 0; i < arity; i++) { |
68 | var sort = sorts.get(i); | 68 | var sort = sorts.get(i); |
69 | if (sort instanceof DataSort<?> dataSort) { | 69 | if (sort instanceof DataSort<?> dataSort) { |
@@ -99,20 +99,20 @@ public class RelationalQueryMetaContext extends AbstractQueryMetaContext { | |||
99 | return flattened; | 99 | return flattened; |
100 | } | 100 | } |
101 | 101 | ||
102 | private static void checkValidIndices(AnyRelationView relationView, Collection<Integer> indices) { | 102 | private static void checkValidIndices(AnySymbolView relationView, Collection<Integer> indices) { |
103 | indices.stream().filter(relationView::invalidIndex).findAny().ifPresent(i -> { | 103 | indices.stream().filter(relationView::invalidIndex).findAny().ifPresent(i -> { |
104 | throw new IllegalArgumentException("Index %d is invalid for %s".formatted(i, relationView)); | 104 | throw new IllegalArgumentException("Index %d is invalid for %s".formatted(i, relationView)); |
105 | }); | 105 | }); |
106 | } | 106 | } |
107 | 107 | ||
108 | public AnyRelationView checkKey(IInputKey key) { | 108 | public AnySymbolView checkKey(IInputKey key) { |
109 | if (!(key instanceof RelationViewWrapper wrapper)) { | 109 | if (!(key instanceof SymbolViewWrapper wrapper)) { |
110 | throw new IllegalArgumentException("The input key %s is not a valid input key".formatted(key)); | 110 | throw new IllegalArgumentException("The input key %s is not a valid input key".formatted(key)); |
111 | } | 111 | } |
112 | var relationView = wrapper.getWrappedKey(); | 112 | var symbolView = wrapper.getWrappedKey(); |
113 | if (!inputKeys.containsKey(relationView)) { | 113 | if (!inputKeys.containsKey(symbolView)) { |
114 | throw new IllegalArgumentException("The input key %s is not present in the model".formatted(key)); | 114 | throw new IllegalArgumentException("The input key %s is not present in the model".formatted(key)); |
115 | } | 115 | } |
116 | return relationView; | 116 | return symbolView; |
117 | } | 117 | } |
118 | } | 118 | } |
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalRuntimeContext.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalRuntimeContext.java index 71943737..0f2daca8 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalRuntimeContext.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/RelationalRuntimeContext.java | |||
@@ -13,9 +13,9 @@ import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | |||
13 | import org.eclipse.viatra.query.runtime.matchers.util.Accuracy; | 13 | import org.eclipse.viatra.query.runtime.matchers.util.Accuracy; |
14 | import tools.refinery.store.model.Model; | 14 | import tools.refinery.store.model.Model; |
15 | import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; | 15 | import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; |
16 | import tools.refinery.store.query.viatra.internal.pquery.RelationViewWrapper; | 16 | import tools.refinery.store.query.viatra.internal.pquery.SymbolViewWrapper; |
17 | import tools.refinery.store.query.viatra.internal.update.ModelUpdateListener; | 17 | import tools.refinery.store.query.viatra.internal.update.ModelUpdateListener; |
18 | import tools.refinery.store.query.view.AnyRelationView; | 18 | import tools.refinery.store.query.view.AnySymbolView; |
19 | 19 | ||
20 | import java.lang.reflect.InvocationTargetException; | 20 | import java.lang.reflect.InvocationTargetException; |
21 | import java.util.Iterator; | 21 | import java.util.Iterator; |
@@ -59,9 +59,9 @@ public class RelationalRuntimeContext implements IQueryRuntimeContext { | |||
59 | 59 | ||
60 | @Override | 60 | @Override |
61 | public boolean isIndexed(IInputKey key, IndexingService service) { | 61 | public boolean isIndexed(IInputKey key, IndexingService service) { |
62 | if (key instanceof RelationViewWrapper wrapper) { | 62 | if (key instanceof SymbolViewWrapper wrapper) { |
63 | var relationalKey = wrapper.getWrappedKey(); | 63 | var symbolViewKey = wrapper.getWrappedKey(); |
64 | return this.modelUpdateListener.containsRelationView(relationalKey); | 64 | return this.modelUpdateListener.containsSymbolView(symbolViewKey); |
65 | } else { | 65 | } else { |
66 | return false; | 66 | return false; |
67 | } | 67 | } |
@@ -74,13 +74,13 @@ public class RelationalRuntimeContext implements IQueryRuntimeContext { | |||
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | AnyRelationView checkKey(IInputKey key) { | 77 | AnySymbolView checkKey(IInputKey key) { |
78 | if (key instanceof RelationViewWrapper wrappedKey) { | 78 | if (key instanceof SymbolViewWrapper wrappedKey) { |
79 | var relationViewKey = wrappedKey.getWrappedKey(); | 79 | var symbolViewKey = wrappedKey.getWrappedKey(); |
80 | if (modelUpdateListener.containsRelationView(relationViewKey)) { | 80 | if (modelUpdateListener.containsSymbolView(symbolViewKey)) { |
81 | return relationViewKey; | 81 | return symbolViewKey; |
82 | } else { | 82 | } else { |
83 | throw new IllegalStateException("Query is asking for non-indexed key %s".formatted(relationViewKey)); | 83 | throw new IllegalStateException("Query is asking for non-indexed key %s".formatted(symbolViewKey)); |
84 | } | 84 | } |
85 | } else { | 85 | } else { |
86 | throw new IllegalStateException("Query is asking for non-relational key"); | 86 | throw new IllegalStateException("Query is asking for non-relational key"); |
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java index 714d41c0..b511a5c7 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java | |||
@@ -29,7 +29,7 @@ import tools.refinery.store.query.term.ConstantTerm; | |||
29 | import tools.refinery.store.query.term.StatefulAggregator; | 29 | import tools.refinery.store.query.term.StatefulAggregator; |
30 | import tools.refinery.store.query.term.StatelessAggregator; | 30 | import tools.refinery.store.query.term.StatelessAggregator; |
31 | import tools.refinery.store.query.term.Variable; | 31 | import tools.refinery.store.query.term.Variable; |
32 | import tools.refinery.store.query.view.AnyRelationView; | 32 | import tools.refinery.store.query.view.AnySymbolView; |
33 | import tools.refinery.store.util.CycleDetectingMapper; | 33 | import tools.refinery.store.util.CycleDetectingMapper; |
34 | 34 | ||
35 | import java.util.*; | 35 | import java.util.*; |
@@ -53,8 +53,8 @@ public class Dnf2PQuery { | |||
53 | return mapper.map(dnfQuery); | 53 | return mapper.map(dnfQuery); |
54 | } | 54 | } |
55 | 55 | ||
56 | public Map<AnyRelationView, IInputKey> getRelationViews() { | 56 | public Map<AnySymbolView, IInputKey> getSymbolViews() { |
57 | return wrapperFactory.getRelationViews(); | 57 | return wrapperFactory.getSymbolViews(); |
58 | } | 58 | } |
59 | 59 | ||
60 | public void hint(Dnf dnf, QueryEvaluationHint hint) { | 60 | public void hint(Dnf dnf, QueryEvaluationHint hint) { |
@@ -165,8 +165,8 @@ public class Dnf2PQuery { | |||
165 | if (constraint instanceof Dnf dnf) { | 165 | if (constraint instanceof Dnf dnf) { |
166 | var pattern = translate(dnf); | 166 | var pattern = translate(dnf); |
167 | new PositivePatternCall(body, substitution, pattern); | 167 | new PositivePatternCall(body, substitution, pattern); |
168 | } else if (constraint instanceof AnyRelationView relationView) { | 168 | } else if (constraint instanceof AnySymbolView symbolView) { |
169 | var inputKey = wrapperFactory.getInputKey(relationView); | 169 | var inputKey = wrapperFactory.getInputKey(symbolView); |
170 | new TypeConstraint(body, substitution, inputKey); | 170 | new TypeConstraint(body, substitution, inputKey); |
171 | } else { | 171 | } else { |
172 | throw new IllegalArgumentException("Unknown Constraint: " + constraint); | 172 | throw new IllegalArgumentException("Unknown Constraint: " + constraint); |
@@ -178,8 +178,8 @@ public class Dnf2PQuery { | |||
178 | PQuery pattern; | 178 | PQuery pattern; |
179 | if (constraint instanceof Dnf dnf) { | 179 | if (constraint instanceof Dnf dnf) { |
180 | pattern = translate(dnf); | 180 | pattern = translate(dnf); |
181 | } else if (constraint instanceof AnyRelationView relationView) { | 181 | } else if (constraint instanceof AnySymbolView symbolView) { |
182 | pattern = wrapperFactory.wrapRelationViewIdentityArguments(relationView); | 182 | pattern = wrapperFactory.wrapSymbolViewIdentityArguments(symbolView); |
183 | } else { | 183 | } else { |
184 | throw new IllegalArgumentException("Unknown Constraint: " + constraint); | 184 | throw new IllegalArgumentException("Unknown Constraint: " + constraint); |
185 | } | 185 | } |
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/QueryWrapperFactory.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/QueryWrapperFactory.java index 30f848a6..0d046455 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/QueryWrapperFactory.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/QueryWrapperFactory.java | |||
@@ -21,8 +21,8 @@ import tools.refinery.store.query.dnf.DnfClause; | |||
21 | import tools.refinery.store.query.dnf.DnfUtils; | 21 | import tools.refinery.store.query.dnf.DnfUtils; |
22 | import tools.refinery.store.query.literal.AbstractCallLiteral; | 22 | import tools.refinery.store.query.literal.AbstractCallLiteral; |
23 | import tools.refinery.store.query.term.Variable; | 23 | import tools.refinery.store.query.term.Variable; |
24 | import tools.refinery.store.query.view.AnyRelationView; | 24 | import tools.refinery.store.query.view.AnySymbolView; |
25 | import tools.refinery.store.query.view.RelationView; | 25 | import tools.refinery.store.query.view.SymbolView; |
26 | import tools.refinery.store.util.CycleDetectingMapper; | 26 | import tools.refinery.store.util.CycleDetectingMapper; |
27 | 27 | ||
28 | import java.util.*; | 28 | import java.util.*; |
@@ -30,7 +30,7 @@ import java.util.function.ToIntFunction; | |||
30 | 30 | ||
31 | class QueryWrapperFactory { | 31 | class QueryWrapperFactory { |
32 | private final Dnf2PQuery dnf2PQuery; | 32 | private final Dnf2PQuery dnf2PQuery; |
33 | private final Map<AnyRelationView, RelationViewWrapper> view2WrapperMap = new LinkedHashMap<>(); | 33 | private final Map<AnySymbolView, SymbolViewWrapper> view2WrapperMap = new LinkedHashMap<>(); |
34 | private final CycleDetectingMapper<RemappedConstraint, RawPQuery> wrapConstraint = new CycleDetectingMapper<>( | 34 | private final CycleDetectingMapper<RemappedConstraint, RawPQuery> wrapConstraint = new CycleDetectingMapper<>( |
35 | RemappedConstraint::toString, this::doWrapConstraint); | 35 | RemappedConstraint::toString, this::doWrapConstraint); |
36 | 36 | ||
@@ -38,12 +38,12 @@ class QueryWrapperFactory { | |||
38 | this.dnf2PQuery = dnf2PQuery; | 38 | this.dnf2PQuery = dnf2PQuery; |
39 | } | 39 | } |
40 | 40 | ||
41 | public PQuery wrapRelationViewIdentityArguments(AnyRelationView relationView) { | 41 | public PQuery wrapSymbolViewIdentityArguments(AnySymbolView symbolView) { |
42 | var identity = new int[relationView.arity()]; | 42 | var identity = new int[symbolView.arity()]; |
43 | for (int i = 0; i < identity.length; i++) { | 43 | for (int i = 0; i < identity.length; i++) { |
44 | identity[i] = i; | 44 | identity[i] = i; |
45 | } | 45 | } |
46 | return maybeWrapConstraint(relationView, identity); | 46 | return maybeWrapConstraint(symbolView, identity); |
47 | } | 47 | } |
48 | public WrappedCall maybeWrapConstraint(AbstractCallLiteral callLiteral, DnfClause clause) { | 48 | public WrappedCall maybeWrapConstraint(AbstractCallLiteral callLiteral, DnfClause clause) { |
49 | var arguments = callLiteral.getArguments(); | 49 | var arguments = callLiteral.getArguments(); |
@@ -112,8 +112,8 @@ class QueryWrapperFactory { | |||
112 | } | 112 | } |
113 | var argumentTuple = Tuples.flatTupleOf(arguments); | 113 | var argumentTuple = Tuples.flatTupleOf(arguments); |
114 | 114 | ||
115 | if (constraint instanceof RelationView<?> relationView) { | 115 | if (constraint instanceof SymbolView<?> view) { |
116 | new TypeConstraint(body, argumentTuple, getInputKey(relationView)); | 116 | new TypeConstraint(body, argumentTuple, getInputKey(view)); |
117 | } else if (constraint instanceof Dnf dnf) { | 117 | } else if (constraint instanceof Dnf dnf) { |
118 | var calledPQuery = dnf2PQuery.translate(dnf); | 118 | var calledPQuery = dnf2PQuery.translate(dnf); |
119 | new PositivePatternCall(body, argumentTuple, calledPQuery); | 119 | new PositivePatternCall(body, argumentTuple, calledPQuery); |
@@ -125,11 +125,11 @@ class QueryWrapperFactory { | |||
125 | return embeddedPQuery; | 125 | return embeddedPQuery; |
126 | } | 126 | } |
127 | 127 | ||
128 | public IInputKey getInputKey(AnyRelationView relationView) { | 128 | public IInputKey getInputKey(AnySymbolView symbolView) { |
129 | return view2WrapperMap.computeIfAbsent(relationView, RelationViewWrapper::new); | 129 | return view2WrapperMap.computeIfAbsent(symbolView, SymbolViewWrapper::new); |
130 | } | 130 | } |
131 | 131 | ||
132 | public Map<AnyRelationView, IInputKey> getRelationViews() { | 132 | public Map<AnySymbolView, IInputKey> getSymbolViews() { |
133 | return Collections.unmodifiableMap(view2WrapperMap); | 133 | return Collections.unmodifiableMap(view2WrapperMap); |
134 | } | 134 | } |
135 | 135 | ||
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RelationViewWrapper.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/SymbolViewWrapper.java index 02da932b..a777613e 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RelationViewWrapper.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/SymbolViewWrapper.java | |||
@@ -6,10 +6,10 @@ | |||
6 | package tools.refinery.store.query.viatra.internal.pquery; | 6 | package tools.refinery.store.query.viatra.internal.pquery; |
7 | 7 | ||
8 | import org.eclipse.viatra.query.runtime.matchers.context.common.BaseInputKeyWrapper; | 8 | import org.eclipse.viatra.query.runtime.matchers.context.common.BaseInputKeyWrapper; |
9 | import tools.refinery.store.query.view.AnyRelationView; | 9 | import tools.refinery.store.query.view.AnySymbolView; |
10 | 10 | ||
11 | public class RelationViewWrapper extends BaseInputKeyWrapper<AnyRelationView> { | 11 | public class SymbolViewWrapper extends BaseInputKeyWrapper<AnySymbolView> { |
12 | public RelationViewWrapper(AnyRelationView wrappedKey) { | 12 | public SymbolViewWrapper(AnySymbolView wrappedKey) { |
13 | super(wrappedKey); | 13 | super(wrappedKey); |
14 | } | 14 | } |
15 | 15 | ||
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/ModelUpdateListener.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/ModelUpdateListener.java index c612574f..986bb0b1 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/ModelUpdateListener.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/ModelUpdateListener.java | |||
@@ -9,43 +9,43 @@ import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; | |||
9 | import org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContextListener; | 9 | import org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContextListener; |
10 | import org.eclipse.viatra.query.runtime.matchers.tuple.ITuple; | 10 | import org.eclipse.viatra.query.runtime.matchers.tuple.ITuple; |
11 | import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; | 11 | import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; |
12 | import tools.refinery.store.query.view.AnyRelationView; | 12 | import tools.refinery.store.query.view.AnySymbolView; |
13 | import tools.refinery.store.query.view.RelationView; | 13 | import tools.refinery.store.query.view.SymbolView; |
14 | 14 | ||
15 | import java.util.HashMap; | 15 | import java.util.HashMap; |
16 | import java.util.Map; | 16 | import java.util.Map; |
17 | 17 | ||
18 | public class ModelUpdateListener { | 18 | public class ModelUpdateListener { |
19 | private final Map<AnyRelationView, RelationViewUpdateListener<?>> relationViewUpdateListeners; | 19 | private final Map<AnySymbolView, SymbolViewUpdateListener<?>> symbolViewUpdateListeners; |
20 | 20 | ||
21 | public ModelUpdateListener(ViatraModelQueryAdapterImpl adapter) { | 21 | public ModelUpdateListener(ViatraModelQueryAdapterImpl adapter) { |
22 | var relationViews = adapter.getStoreAdapter().getInputKeys().keySet(); | 22 | var symbolViews = adapter.getStoreAdapter().getInputKeys().keySet(); |
23 | relationViewUpdateListeners = new HashMap<>(relationViews.size()); | 23 | symbolViewUpdateListeners = new HashMap<>(symbolViews.size()); |
24 | for (var relationView : relationViews) { | 24 | for (var symbolView : symbolViews) { |
25 | registerView(adapter, (RelationView<?>) relationView); | 25 | registerView(adapter, (SymbolView<?>) symbolView); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | private <T> void registerView(ViatraModelQueryAdapterImpl adapter, RelationView<T> relationView) { | 29 | private <T> void registerView(ViatraModelQueryAdapterImpl adapter, SymbolView<T> view) { |
30 | var model = adapter.getModel(); | 30 | var model = adapter.getModel(); |
31 | var interpretation = model.getInterpretation(relationView.getSymbol()); | 31 | var interpretation = model.getInterpretation(view.getSymbol()); |
32 | var listener = RelationViewUpdateListener.of(adapter, relationView, interpretation); | 32 | var listener = SymbolViewUpdateListener.of(adapter, view, interpretation); |
33 | relationViewUpdateListeners.put(relationView, listener); | 33 | symbolViewUpdateListeners.put(view, listener); |
34 | } | 34 | } |
35 | 35 | ||
36 | public boolean containsRelationView(AnyRelationView relationView) { | 36 | public boolean containsSymbolView(AnySymbolView relationView) { |
37 | return relationViewUpdateListeners.containsKey(relationView); | 37 | return symbolViewUpdateListeners.containsKey(relationView); |
38 | } | 38 | } |
39 | 39 | ||
40 | public void addListener(IInputKey key, AnyRelationView relationView, ITuple seed, | 40 | public void addListener(IInputKey key, AnySymbolView symbolView, ITuple seed, |
41 | IQueryRuntimeContextListener listener) { | 41 | IQueryRuntimeContextListener listener) { |
42 | var relationViewUpdateListener = relationViewUpdateListeners.get(relationView); | 42 | var symbolViewUpdateListener = symbolViewUpdateListeners.get(symbolView); |
43 | relationViewUpdateListener.addFilter(key, seed, listener); | 43 | symbolViewUpdateListener.addFilter(key, seed, listener); |
44 | } | 44 | } |
45 | 45 | ||
46 | public void removeListener(IInputKey key, AnyRelationView relationView, ITuple seed, | 46 | public void removeListener(IInputKey key, AnySymbolView symbolView, ITuple seed, |
47 | IQueryRuntimeContextListener listener) { | 47 | IQueryRuntimeContextListener listener) { |
48 | var relationViewUpdateListener = relationViewUpdateListeners.get(relationView); | 48 | var symbolViewUpdateListener = symbolViewUpdateListeners.get(symbolView); |
49 | relationViewUpdateListener.removeFilter(key, seed, listener); | 49 | symbolViewUpdateListener.removeFilter(key, seed, listener); |
50 | } | 50 | } |
51 | } | 51 | } |
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/RelationViewUpdateListener.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/SymbolViewUpdateListener.java index 185e4ebc..f1a2ac7c 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/RelationViewUpdateListener.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/SymbolViewUpdateListener.java | |||
@@ -12,18 +12,18 @@ import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | |||
12 | import tools.refinery.store.model.Interpretation; | 12 | import tools.refinery.store.model.Interpretation; |
13 | import tools.refinery.store.model.InterpretationListener; | 13 | import tools.refinery.store.model.InterpretationListener; |
14 | import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; | 14 | import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; |
15 | import tools.refinery.store.query.view.RelationView; | 15 | import tools.refinery.store.query.view.SymbolView; |
16 | import tools.refinery.store.query.view.TuplePreservingRelationView; | 16 | import tools.refinery.store.query.view.TuplePreservingView; |
17 | 17 | ||
18 | import java.util.ArrayList; | 18 | import java.util.ArrayList; |
19 | import java.util.List; | 19 | import java.util.List; |
20 | 20 | ||
21 | public abstract class RelationViewUpdateListener<T> implements InterpretationListener<T> { | 21 | public abstract class SymbolViewUpdateListener<T> implements InterpretationListener<T> { |
22 | private final ViatraModelQueryAdapterImpl adapter; | 22 | private final ViatraModelQueryAdapterImpl adapter; |
23 | private final Interpretation<T> interpretation; | 23 | private final Interpretation<T> interpretation; |
24 | private final List<RelationViewFilter> filters = new ArrayList<>(); | 24 | private final List<RelationViewFilter> filters = new ArrayList<>(); |
25 | 25 | ||
26 | protected RelationViewUpdateListener(ViatraModelQueryAdapterImpl adapter, Interpretation<T> interpretation) { | 26 | protected SymbolViewUpdateListener(ViatraModelQueryAdapterImpl adapter, Interpretation<T> interpretation) { |
27 | this.adapter = adapter; | 27 | this.adapter = adapter; |
28 | this.interpretation = interpretation; | 28 | this.interpretation = interpretation; |
29 | } | 29 | } |
@@ -53,13 +53,13 @@ public abstract class RelationViewUpdateListener<T> implements InterpretationLis | |||
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | public static <T> RelationViewUpdateListener<T> of(ViatraModelQueryAdapterImpl adapter, | 56 | public static <T> SymbolViewUpdateListener<T> of(ViatraModelQueryAdapterImpl adapter, |
57 | RelationView<T> relationView, | 57 | SymbolView<T> view, |
58 | Interpretation<T> interpretation) { | 58 | Interpretation<T> interpretation) { |
59 | if (relationView instanceof TuplePreservingRelationView<T> tuplePreservingRelationView) { | 59 | if (view instanceof TuplePreservingView<T> tuplePreservingRelationView) { |
60 | return new TuplePreservingRelationViewUpdateListener<>(adapter, tuplePreservingRelationView, | 60 | return new TuplePreservingViewUpdateListener<>(adapter, tuplePreservingRelationView, |
61 | interpretation); | 61 | interpretation); |
62 | } | 62 | } |
63 | return new TupleChangingRelationViewUpdateListener<>(adapter, relationView, interpretation); | 63 | return new TupleChangingViewUpdateListener<>(adapter, view, interpretation); |
64 | } | 64 | } |
65 | } | 65 | } |
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingRelationViewUpdateListener.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingViewUpdateListener.java index be4951af..45d35571 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingRelationViewUpdateListener.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TupleChangingViewUpdateListener.java | |||
@@ -8,37 +8,37 @@ package tools.refinery.store.query.viatra.internal.update; | |||
8 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | 8 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; |
9 | import tools.refinery.store.model.Interpretation; | 9 | import tools.refinery.store.model.Interpretation; |
10 | import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; | 10 | import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; |
11 | import tools.refinery.store.query.view.RelationView; | 11 | import tools.refinery.store.query.view.SymbolView; |
12 | import tools.refinery.store.tuple.Tuple; | 12 | import tools.refinery.store.tuple.Tuple; |
13 | 13 | ||
14 | import java.util.Arrays; | 14 | import java.util.Arrays; |
15 | 15 | ||
16 | public class TupleChangingRelationViewUpdateListener<T> extends RelationViewUpdateListener<T> { | 16 | public class TupleChangingViewUpdateListener<T> extends SymbolViewUpdateListener<T> { |
17 | private final RelationView<T> relationView; | 17 | private final SymbolView<T> view; |
18 | 18 | ||
19 | TupleChangingRelationViewUpdateListener(ViatraModelQueryAdapterImpl adapter, RelationView<T> relationView, | 19 | TupleChangingViewUpdateListener(ViatraModelQueryAdapterImpl adapter, SymbolView<T> view, |
20 | Interpretation<T> interpretation) { | 20 | Interpretation<T> interpretation) { |
21 | super(adapter, interpretation); | 21 | super(adapter, interpretation); |
22 | this.relationView = relationView; | 22 | this.view = view; |
23 | } | 23 | } |
24 | 24 | ||
25 | @Override | 25 | @Override |
26 | public void put(Tuple key, T fromValue, T toValue, boolean restoring) { | 26 | public void put(Tuple key, T fromValue, T toValue, boolean restoring) { |
27 | boolean fromPresent = relationView.filter(key, fromValue); | 27 | boolean fromPresent = view.filter(key, fromValue); |
28 | boolean toPresent = relationView.filter(key, toValue); | 28 | boolean toPresent = view.filter(key, toValue); |
29 | if (fromPresent) { | 29 | if (fromPresent) { |
30 | if (toPresent) { // value change | 30 | if (toPresent) { // value change |
31 | var fromArray = relationView.forwardMap(key, fromValue); | 31 | var fromArray = view.forwardMap(key, fromValue); |
32 | var toArray = relationView.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(relationView.forwardMap(key, fromValue)), false); | 38 | processUpdate(Tuples.flatTupleOf(view.forwardMap(key, fromValue)), false); |
39 | } | 39 | } |
40 | } else if (toPresent) { // toValue appears | 40 | } else if (toPresent) { // toValue appears |
41 | processUpdate(Tuples.flatTupleOf(relationView.forwardMap(key, toValue)), true); | 41 | processUpdate(Tuples.flatTupleOf(view.forwardMap(key, toValue)), true); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | } | 44 | } |
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TuplePreservingRelationViewUpdateListener.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TuplePreservingViewUpdateListener.java index 9638266b..c18dbafb 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TuplePreservingRelationViewUpdateListener.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/update/TuplePreservingViewUpdateListener.java | |||
@@ -8,14 +8,14 @@ package tools.refinery.store.query.viatra.internal.update; | |||
8 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | 8 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; |
9 | import tools.refinery.store.model.Interpretation; | 9 | import tools.refinery.store.model.Interpretation; |
10 | import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; | 10 | import tools.refinery.store.query.viatra.internal.ViatraModelQueryAdapterImpl; |
11 | import tools.refinery.store.query.view.TuplePreservingRelationView; | 11 | import tools.refinery.store.query.view.TuplePreservingView; |
12 | import tools.refinery.store.tuple.Tuple; | 12 | import tools.refinery.store.tuple.Tuple; |
13 | 13 | ||
14 | public class TuplePreservingRelationViewUpdateListener<T> extends RelationViewUpdateListener<T> { | 14 | public class TuplePreservingViewUpdateListener<T> extends SymbolViewUpdateListener<T> { |
15 | private final TuplePreservingRelationView<T> view; | 15 | private final TuplePreservingView<T> view; |
16 | 16 | ||
17 | TuplePreservingRelationViewUpdateListener(ViatraModelQueryAdapterImpl adapter, | 17 | TuplePreservingViewUpdateListener(ViatraModelQueryAdapterImpl adapter, TuplePreservingView<T> view, |
18 | TuplePreservingRelationView<T> view, Interpretation<T> interpretation) { | 18 | Interpretation<T> interpretation) { |
19 | super(adapter, interpretation); | 19 | super(adapter, interpretation); |
20 | this.view = view; | 20 | this.view = view; |
21 | } | 21 | } |