diff options
Diffstat (limited to 'subprojects')
31 files changed, 279 insertions, 294 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 | } |
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/DiagonalQueryTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/DiagonalQueryTest.java index da4aba7f..5cffef71 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/DiagonalQueryTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/DiagonalQueryTest.java | |||
@@ -12,8 +12,8 @@ import tools.refinery.store.query.dnf.Dnf; | |||
12 | import tools.refinery.store.query.dnf.Query; | 12 | import tools.refinery.store.query.dnf.Query; |
13 | import tools.refinery.store.query.term.Variable; | 13 | import tools.refinery.store.query.term.Variable; |
14 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; | 14 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; |
15 | import tools.refinery.store.query.view.FunctionalRelationView; | 15 | import tools.refinery.store.query.view.FunctionView; |
16 | import tools.refinery.store.query.view.KeyOnlyRelationView; | 16 | import tools.refinery.store.query.view.KeyOnlyView; |
17 | import tools.refinery.store.representation.Symbol; | 17 | import tools.refinery.store.representation.Symbol; |
18 | import tools.refinery.store.tuple.Tuple; | 18 | import tools.refinery.store.tuple.Tuple; |
19 | 19 | ||
@@ -30,8 +30,8 @@ class DiagonalQueryTest { | |||
30 | void inputKeyNegationTest(QueryEvaluationHint hint) { | 30 | void inputKeyNegationTest(QueryEvaluationHint hint) { |
31 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 31 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
32 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); | 32 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); |
33 | var personView = new KeyOnlyRelationView<>(person); | 33 | var personView = new KeyOnlyView<>(person); |
34 | var symbolView = new KeyOnlyRelationView<>(symbol); | 34 | var symbolView = new KeyOnlyView<>(symbol); |
35 | 35 | ||
36 | var p1 = Variable.of("p1"); | 36 | var p1 = Variable.of("p1"); |
37 | var p2 = Variable.of("p2"); | 37 | var p2 = Variable.of("p2"); |
@@ -78,8 +78,8 @@ class DiagonalQueryTest { | |||
78 | void subQueryNegationTest(QueryEvaluationHint hint) { | 78 | void subQueryNegationTest(QueryEvaluationHint hint) { |
79 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 79 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
80 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); | 80 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); |
81 | var personView = new KeyOnlyRelationView<>(person); | 81 | var personView = new KeyOnlyView<>(person); |
82 | var symbolView = new KeyOnlyRelationView<>(symbol); | 82 | var symbolView = new KeyOnlyView<>(symbol); |
83 | 83 | ||
84 | var p1 = Variable.of("p1"); | 84 | var p1 = Variable.of("p1"); |
85 | var p2 = Variable.of("p2"); | 85 | var p2 = Variable.of("p2"); |
@@ -139,8 +139,8 @@ class DiagonalQueryTest { | |||
139 | void inputKeyCountTest(QueryEvaluationHint hint) { | 139 | void inputKeyCountTest(QueryEvaluationHint hint) { |
140 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 140 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
141 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); | 141 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); |
142 | var personView = new KeyOnlyRelationView<>(person); | 142 | var personView = new KeyOnlyView<>(person); |
143 | var symbolView = new KeyOnlyRelationView<>(symbol); | 143 | var symbolView = new KeyOnlyView<>(symbol); |
144 | 144 | ||
145 | var p1 = Variable.of("p1"); | 145 | var p1 = Variable.of("p1"); |
146 | var p2 = Variable.of("p2"); | 146 | var p2 = Variable.of("p2"); |
@@ -190,8 +190,8 @@ class DiagonalQueryTest { | |||
190 | void subQueryCountTest(QueryEvaluationHint hint) { | 190 | void subQueryCountTest(QueryEvaluationHint hint) { |
191 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 191 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
192 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); | 192 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); |
193 | var personView = new KeyOnlyRelationView<>(person); | 193 | var personView = new KeyOnlyView<>(person); |
194 | var symbolView = new KeyOnlyRelationView<>(symbol); | 194 | var symbolView = new KeyOnlyView<>(symbol); |
195 | 195 | ||
196 | var p1 = Variable.of("p1"); | 196 | var p1 = Variable.of("p1"); |
197 | var p2 = Variable.of("p2"); | 197 | var p2 = Variable.of("p2"); |
@@ -254,8 +254,8 @@ class DiagonalQueryTest { | |||
254 | void inputKeyAggregationTest(QueryEvaluationHint hint) { | 254 | void inputKeyAggregationTest(QueryEvaluationHint hint) { |
255 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 255 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
256 | var symbol = new Symbol<>("symbol", 4, Integer.class, null); | 256 | var symbol = new Symbol<>("symbol", 4, Integer.class, null); |
257 | var personView = new KeyOnlyRelationView<>(person); | 257 | var personView = new KeyOnlyView<>(person); |
258 | var symbolView = new FunctionalRelationView<>(symbol); | 258 | var symbolView = new FunctionView<>(symbol); |
259 | 259 | ||
260 | var p1 = Variable.of("p1"); | 260 | var p1 = Variable.of("p1"); |
261 | var p2 = Variable.of("p2"); | 261 | var p2 = Variable.of("p2"); |
@@ -306,8 +306,8 @@ class DiagonalQueryTest { | |||
306 | void subQueryAggregationTest(QueryEvaluationHint hint) { | 306 | void subQueryAggregationTest(QueryEvaluationHint hint) { |
307 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 307 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
308 | var symbol = new Symbol<>("symbol", 4, Integer.class, null); | 308 | var symbol = new Symbol<>("symbol", 4, Integer.class, null); |
309 | var personView = new KeyOnlyRelationView<>(person); | 309 | var personView = new KeyOnlyView<>(person); |
310 | var symbolView = new FunctionalRelationView<>(symbol); | 310 | var symbolView = new FunctionView<>(symbol); |
311 | 311 | ||
312 | var p1 = Variable.of("p1"); | 312 | var p1 = Variable.of("p1"); |
313 | var p2 = Variable.of("p2"); | 313 | var p2 = Variable.of("p2"); |
@@ -374,8 +374,8 @@ class DiagonalQueryTest { | |||
374 | void inputKeyTransitiveTest(QueryEvaluationHint hint) { | 374 | void inputKeyTransitiveTest(QueryEvaluationHint hint) { |
375 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 375 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
376 | var symbol = new Symbol<>("symbol", 2, Boolean.class, false); | 376 | var symbol = new Symbol<>("symbol", 2, Boolean.class, false); |
377 | var personView = new KeyOnlyRelationView<>(person); | 377 | var personView = new KeyOnlyView<>(person); |
378 | var symbolView = new KeyOnlyRelationView<>(symbol); | 378 | var symbolView = new KeyOnlyView<>(symbol); |
379 | 379 | ||
380 | var p1 = Variable.of("p1"); | 380 | var p1 = Variable.of("p1"); |
381 | var query = Query.builder("Diagonal") | 381 | var query = Query.builder("Diagonal") |
@@ -420,8 +420,8 @@ class DiagonalQueryTest { | |||
420 | void subQueryTransitiveTest(QueryEvaluationHint hint) { | 420 | void subQueryTransitiveTest(QueryEvaluationHint hint) { |
421 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 421 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
422 | var symbol = new Symbol<>("symbol", 2, Boolean.class, false); | 422 | var symbol = new Symbol<>("symbol", 2, Boolean.class, false); |
423 | var personView = new KeyOnlyRelationView<>(person); | 423 | var personView = new KeyOnlyView<>(person); |
424 | var symbolView = new KeyOnlyRelationView<>(symbol); | 424 | var symbolView = new KeyOnlyView<>(symbol); |
425 | 425 | ||
426 | var p1 = Variable.of("p1"); | 426 | var p1 = Variable.of("p1"); |
427 | var p2 = Variable.of("p2"); | 427 | var p2 = Variable.of("p2"); |
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java index 3af67a50..19584273 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java | |||
@@ -13,9 +13,9 @@ import tools.refinery.store.query.dnf.Dnf; | |||
13 | import tools.refinery.store.query.dnf.Query; | 13 | import tools.refinery.store.query.dnf.Query; |
14 | import tools.refinery.store.query.term.Variable; | 14 | import tools.refinery.store.query.term.Variable; |
15 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; | 15 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; |
16 | import tools.refinery.store.query.view.FilteredRelationView; | 16 | import tools.refinery.store.query.view.FilteredView; |
17 | import tools.refinery.store.query.view.FunctionalRelationView; | 17 | import tools.refinery.store.query.view.FunctionView; |
18 | import tools.refinery.store.query.view.KeyOnlyRelationView; | 18 | import tools.refinery.store.query.view.KeyOnlyView; |
19 | import tools.refinery.store.representation.Symbol; | 19 | import tools.refinery.store.representation.Symbol; |
20 | import tools.refinery.store.representation.TruthValue; | 20 | import tools.refinery.store.representation.TruthValue; |
21 | import tools.refinery.store.tuple.Tuple; | 21 | import tools.refinery.store.tuple.Tuple; |
@@ -38,8 +38,8 @@ class FunctionalQueryTest { | |||
38 | void inputKeyTest(QueryEvaluationHint hint) { | 38 | void inputKeyTest(QueryEvaluationHint hint) { |
39 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 39 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
40 | var age = new Symbol<>("age", 1, Integer.class, null); | 40 | var age = new Symbol<>("age", 1, Integer.class, null); |
41 | var personView = new KeyOnlyRelationView<>(person); | 41 | var personView = new KeyOnlyView<>(person); |
42 | var ageView = new FunctionalRelationView<>(age); | 42 | var ageView = new FunctionView<>(age); |
43 | 43 | ||
44 | var p1 = Variable.of("p1"); | 44 | var p1 = Variable.of("p1"); |
45 | var x = Variable.of("x", Integer.class); | 45 | var x = Variable.of("x", Integer.class); |
@@ -84,8 +84,8 @@ class FunctionalQueryTest { | |||
84 | void predicateTest(QueryEvaluationHint hint) { | 84 | void predicateTest(QueryEvaluationHint hint) { |
85 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 85 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
86 | var age = new Symbol<>("age", 1, Integer.class, null); | 86 | var age = new Symbol<>("age", 1, Integer.class, null); |
87 | var personView = new KeyOnlyRelationView<>(person); | 87 | var personView = new KeyOnlyView<>(person); |
88 | var ageView = new FunctionalRelationView<>(age); | 88 | var ageView = new FunctionView<>(age); |
89 | 89 | ||
90 | var p1 = Variable.of("p1"); | 90 | var p1 = Variable.of("p1"); |
91 | var x = Variable.of("x", Integer.class); | 91 | var x = Variable.of("x", Integer.class); |
@@ -137,8 +137,8 @@ class FunctionalQueryTest { | |||
137 | void computationTest(QueryEvaluationHint hint) { | 137 | void computationTest(QueryEvaluationHint hint) { |
138 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 138 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
139 | var age = new Symbol<>("age", 1, Integer.class, null); | 139 | var age = new Symbol<>("age", 1, Integer.class, null); |
140 | var personView = new KeyOnlyRelationView<>(person); | 140 | var personView = new KeyOnlyView<>(person); |
141 | var ageView = new FunctionalRelationView<>(age); | 141 | var ageView = new FunctionView<>(age); |
142 | 142 | ||
143 | var p1 = Variable.of("p1"); | 143 | var p1 = Variable.of("p1"); |
144 | var x = Variable.of("x", Integer.class); | 144 | var x = Variable.of("x", Integer.class); |
@@ -184,8 +184,8 @@ class FunctionalQueryTest { | |||
184 | void inputKeyCountTest(QueryEvaluationHint hint) { | 184 | void inputKeyCountTest(QueryEvaluationHint hint) { |
185 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 185 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
186 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 186 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
187 | var personView = new KeyOnlyRelationView<>(person); | 187 | var personView = new KeyOnlyView<>(person); |
188 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 188 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
189 | 189 | ||
190 | var p1 = Variable.of("p1"); | 190 | var p1 = Variable.of("p1"); |
191 | var p2 = Variable.of("p2"); | 191 | var p2 = Variable.of("p2"); |
@@ -233,8 +233,8 @@ class FunctionalQueryTest { | |||
233 | void predicateCountTest(QueryEvaluationHint hint) { | 233 | void predicateCountTest(QueryEvaluationHint hint) { |
234 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 234 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
235 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 235 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
236 | var personView = new KeyOnlyRelationView<>(person); | 236 | var personView = new KeyOnlyView<>(person); |
237 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 237 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
238 | 238 | ||
239 | var p1 = Variable.of("p1"); | 239 | var p1 = Variable.of("p1"); |
240 | var p2 = Variable.of("p2"); | 240 | var p2 = Variable.of("p2"); |
@@ -289,7 +289,7 @@ class FunctionalQueryTest { | |||
289 | @QueryEngineTest | 289 | @QueryEngineTest |
290 | void inputKeyAggregationTest(QueryEvaluationHint hint) { | 290 | void inputKeyAggregationTest(QueryEvaluationHint hint) { |
291 | var age = new Symbol<>("age", 1, Integer.class, null); | 291 | var age = new Symbol<>("age", 1, Integer.class, null); |
292 | var ageView = new FunctionalRelationView<>(age); | 292 | var ageView = new FunctionView<>(age); |
293 | 293 | ||
294 | var p1 = Variable.of("p1"); | 294 | var p1 = Variable.of("p1"); |
295 | var x = Variable.of("x", Integer.class); | 295 | var x = Variable.of("x", Integer.class); |
@@ -324,8 +324,8 @@ class FunctionalQueryTest { | |||
324 | void predicateAggregationTest(QueryEvaluationHint hint) { | 324 | void predicateAggregationTest(QueryEvaluationHint hint) { |
325 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 325 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
326 | var age = new Symbol<>("age", 1, Integer.class, null); | 326 | var age = new Symbol<>("age", 1, Integer.class, null); |
327 | var personView = new KeyOnlyRelationView<>(person); | 327 | var personView = new KeyOnlyView<>(person); |
328 | var ageView = new FunctionalRelationView<>(age); | 328 | var ageView = new FunctionView<>(age); |
329 | 329 | ||
330 | var p1 = Variable.of("p1"); | 330 | var p1 = Variable.of("p1"); |
331 | var x = Variable.of("x", Integer.class); | 331 | var x = Variable.of("x", Integer.class); |
@@ -371,8 +371,8 @@ class FunctionalQueryTest { | |||
371 | void extremeValueTest(QueryEvaluationHint hint) { | 371 | void extremeValueTest(QueryEvaluationHint hint) { |
372 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 372 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
373 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 373 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
374 | var personView = new KeyOnlyRelationView<>(person); | 374 | var personView = new KeyOnlyView<>(person); |
375 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 375 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
376 | 376 | ||
377 | var p1 = Variable.of("p1"); | 377 | var p1 = Variable.of("p1"); |
378 | var p2 = Variable.of("p2"); | 378 | var p2 = Variable.of("p2"); |
@@ -447,8 +447,8 @@ class FunctionalQueryTest { | |||
447 | void invalidComputationTest(QueryEvaluationHint hint) { | 447 | void invalidComputationTest(QueryEvaluationHint hint) { |
448 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 448 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
449 | var age = new Symbol<>("age", 1, Integer.class, null); | 449 | var age = new Symbol<>("age", 1, Integer.class, null); |
450 | var personView = new KeyOnlyRelationView<>(person); | 450 | var personView = new KeyOnlyView<>(person); |
451 | var ageView = new FunctionalRelationView<>(age); | 451 | var ageView = new FunctionView<>(age); |
452 | 452 | ||
453 | var p1 = Variable.of("p1"); | 453 | var p1 = Variable.of("p1"); |
454 | var x = Variable.of("x", Integer.class); | 454 | var x = Variable.of("x", Integer.class); |
@@ -494,8 +494,8 @@ class FunctionalQueryTest { | |||
494 | void invalidAssumeTest(QueryEvaluationHint hint) { | 494 | void invalidAssumeTest(QueryEvaluationHint hint) { |
495 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 495 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
496 | var age = new Symbol<>("age", 1, Integer.class, null); | 496 | var age = new Symbol<>("age", 1, Integer.class, null); |
497 | var personView = new KeyOnlyRelationView<>(person); | 497 | var personView = new KeyOnlyView<>(person); |
498 | var ageView = new FunctionalRelationView<>(age); | 498 | var ageView = new FunctionView<>(age); |
499 | 499 | ||
500 | var p1 = Variable.of("p1"); | 500 | var p1 = Variable.of("p1"); |
501 | var x = Variable.of("x", Integer.class); | 501 | var x = Variable.of("x", Integer.class); |
@@ -543,9 +543,9 @@ class FunctionalQueryTest { | |||
543 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 543 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
544 | var age = new Symbol<>("age", 1, Integer.class, null); | 544 | var age = new Symbol<>("age", 1, Integer.class, null); |
545 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 545 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
546 | var personView = new KeyOnlyRelationView<>(person); | 546 | var personView = new KeyOnlyView<>(person); |
547 | var ageView = new FunctionalRelationView<>(age); | 547 | var ageView = new FunctionView<>(age); |
548 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 548 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
549 | 549 | ||
550 | var p1 = Variable.of("p1"); | 550 | var p1 = Variable.of("p1"); |
551 | var p2 = Variable.of("p2"); | 551 | var p2 = Variable.of("p2"); |
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 e82f0a15..11ee98f5 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 | |||
@@ -13,9 +13,9 @@ import tools.refinery.store.query.dnf.Dnf; | |||
13 | import tools.refinery.store.query.dnf.Query; | 13 | import tools.refinery.store.query.dnf.Query; |
14 | import tools.refinery.store.query.term.Variable; | 14 | import tools.refinery.store.query.term.Variable; |
15 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; | 15 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; |
16 | import tools.refinery.store.query.view.FilteredRelationView; | 16 | import tools.refinery.store.query.view.FilteredView; |
17 | import tools.refinery.store.query.view.FunctionalRelationView; | 17 | import tools.refinery.store.query.view.FunctionView; |
18 | import tools.refinery.store.query.view.KeyOnlyRelationView; | 18 | import tools.refinery.store.query.view.KeyOnlyView; |
19 | import tools.refinery.store.representation.Symbol; | 19 | import tools.refinery.store.representation.Symbol; |
20 | import tools.refinery.store.representation.TruthValue; | 20 | import tools.refinery.store.representation.TruthValue; |
21 | import tools.refinery.store.tuple.Tuple; | 21 | import tools.refinery.store.tuple.Tuple; |
@@ -34,7 +34,7 @@ class QueryTest { | |||
34 | void typeConstraintTest(QueryEvaluationHint hint) { | 34 | void typeConstraintTest(QueryEvaluationHint hint) { |
35 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 35 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
36 | var asset = new Symbol<>("Asset", 1, Boolean.class, false); | 36 | var asset = new Symbol<>("Asset", 1, Boolean.class, false); |
37 | var personView = new KeyOnlyRelationView<>(person); | 37 | var personView = new KeyOnlyView<>(person); |
38 | 38 | ||
39 | var p1 = Variable.of("p1"); | 39 | var p1 = Variable.of("p1"); |
40 | var predicate = Query.builder("TypeConstraint") | 40 | var predicate = Query.builder("TypeConstraint") |
@@ -73,8 +73,8 @@ class QueryTest { | |||
73 | void relationConstraintTest(QueryEvaluationHint hint) { | 73 | void relationConstraintTest(QueryEvaluationHint hint) { |
74 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 74 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
75 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 75 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
76 | var personView = new KeyOnlyRelationView<>(person); | 76 | var personView = new KeyOnlyView<>(person); |
77 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 77 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
78 | 78 | ||
79 | var p1 = Variable.of("p1"); | 79 | var p1 = Variable.of("p1"); |
80 | var p2 = Variable.of("p2"); | 80 | var p2 = Variable.of("p2"); |
@@ -122,8 +122,8 @@ class QueryTest { | |||
122 | void existTest(QueryEvaluationHint hint) { | 122 | void existTest(QueryEvaluationHint hint) { |
123 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 123 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
124 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 124 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
125 | var personView = new KeyOnlyRelationView<>(person); | 125 | var personView = new KeyOnlyView<>(person); |
126 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 126 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
127 | 127 | ||
128 | var p1 = Variable.of("p1"); | 128 | var p1 = Variable.of("p1"); |
129 | var p2 = Variable.of("p2"); | 129 | var p2 = Variable.of("p2"); |
@@ -172,9 +172,9 @@ class QueryTest { | |||
172 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 172 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
173 | var animal = new Symbol<>("Animal", 1, Boolean.class, false); | 173 | var animal = new Symbol<>("Animal", 1, Boolean.class, false); |
174 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 174 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
175 | var personView = new KeyOnlyRelationView<>(person); | 175 | var personView = new KeyOnlyView<>(person); |
176 | var animalView = new KeyOnlyRelationView<>(animal); | 176 | var animalView = new KeyOnlyView<>(animal); |
177 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 177 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
178 | 178 | ||
179 | var p1 = Variable.of("p1"); | 179 | var p1 = Variable.of("p1"); |
180 | var p2 = Variable.of("p2"); | 180 | var p2 = Variable.of("p2"); |
@@ -230,7 +230,7 @@ class QueryTest { | |||
230 | @QueryEngineTest | 230 | @QueryEngineTest |
231 | void equalityTest(QueryEvaluationHint hint) { | 231 | void equalityTest(QueryEvaluationHint hint) { |
232 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 232 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
233 | var personView = new KeyOnlyRelationView<>(person); | 233 | var personView = new KeyOnlyView<>(person); |
234 | 234 | ||
235 | var p1 = Variable.of("p1"); | 235 | var p1 = Variable.of("p1"); |
236 | var p2 = Variable.of("p2"); | 236 | var p2 = Variable.of("p2"); |
@@ -273,8 +273,8 @@ class QueryTest { | |||
273 | void inequalityTest(QueryEvaluationHint hint) { | 273 | void inequalityTest(QueryEvaluationHint hint) { |
274 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 274 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
275 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 275 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
276 | var personView = new KeyOnlyRelationView<>(person); | 276 | var personView = new KeyOnlyView<>(person); |
277 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 277 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
278 | 278 | ||
279 | var p1 = Variable.of("p1"); | 279 | var p1 = Variable.of("p1"); |
280 | var p2 = Variable.of("p2"); | 280 | var p2 = Variable.of("p2"); |
@@ -322,8 +322,8 @@ class QueryTest { | |||
322 | void patternCallTest(QueryEvaluationHint hint) { | 322 | void patternCallTest(QueryEvaluationHint hint) { |
323 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 323 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
324 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 324 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
325 | var personView = new KeyOnlyRelationView<>(person); | 325 | var personView = new KeyOnlyView<>(person); |
326 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 326 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
327 | 327 | ||
328 | var p1 = Variable.of("p1"); | 328 | var p1 = Variable.of("p1"); |
329 | var p2 = Variable.of("p2"); | 329 | var p2 = Variable.of("p2"); |
@@ -381,8 +381,8 @@ class QueryTest { | |||
381 | void negativeRelationViewTest(QueryEvaluationHint hint) { | 381 | void negativeRelationViewTest(QueryEvaluationHint hint) { |
382 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 382 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
383 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 383 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
384 | var personView = new KeyOnlyRelationView<>(person); | 384 | var personView = new KeyOnlyView<>(person); |
385 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 385 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
386 | 386 | ||
387 | var p1 = Variable.of("p1"); | 387 | var p1 = Variable.of("p1"); |
388 | var p2 = Variable.of("p2"); | 388 | var p2 = Variable.of("p2"); |
@@ -435,8 +435,8 @@ class QueryTest { | |||
435 | void negativePatternCallTest(QueryEvaluationHint hint) { | 435 | void negativePatternCallTest(QueryEvaluationHint hint) { |
436 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 436 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
437 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 437 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
438 | var personView = new KeyOnlyRelationView<>(person); | 438 | var personView = new KeyOnlyView<>(person); |
439 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 439 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
440 | 440 | ||
441 | var p1 = Variable.of("p1"); | 441 | var p1 = Variable.of("p1"); |
442 | var p2 = Variable.of("p2"); | 442 | var p2 = Variable.of("p2"); |
@@ -500,8 +500,8 @@ class QueryTest { | |||
500 | void negativeRelationViewWithQuantificationTest(QueryEvaluationHint hint) { | 500 | void negativeRelationViewWithQuantificationTest(QueryEvaluationHint hint) { |
501 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 501 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
502 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 502 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
503 | var personView = new KeyOnlyRelationView<>(person); | 503 | var personView = new KeyOnlyView<>(person); |
504 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 504 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
505 | 505 | ||
506 | var p1 = Variable.of("p1"); | 506 | var p1 = Variable.of("p1"); |
507 | var p2 = Variable.of("p2"); | 507 | var p2 = Variable.of("p2"); |
@@ -547,8 +547,8 @@ class QueryTest { | |||
547 | void negativeWithQuantificationTest(QueryEvaluationHint hint) { | 547 | void negativeWithQuantificationTest(QueryEvaluationHint hint) { |
548 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 548 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
549 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 549 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
550 | var personView = new KeyOnlyRelationView<>(person); | 550 | var personView = new KeyOnlyView<>(person); |
551 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 551 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
552 | 552 | ||
553 | var p1 = Variable.of("p1"); | 553 | var p1 = Variable.of("p1"); |
554 | var p2 = Variable.of("p2"); | 554 | var p2 = Variable.of("p2"); |
@@ -603,8 +603,8 @@ class QueryTest { | |||
603 | void transitiveRelationViewTest(QueryEvaluationHint hint) { | 603 | void transitiveRelationViewTest(QueryEvaluationHint hint) { |
604 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 604 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
605 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 605 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
606 | var personView = new KeyOnlyRelationView<>(person); | 606 | var personView = new KeyOnlyView<>(person); |
607 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 607 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
608 | 608 | ||
609 | var p1 = Variable.of("p1"); | 609 | var p1 = Variable.of("p1"); |
610 | var p2 = Variable.of("p2"); | 610 | var p2 = Variable.of("p2"); |
@@ -656,8 +656,8 @@ class QueryTest { | |||
656 | void transitivePatternCallTest(QueryEvaluationHint hint) { | 656 | void transitivePatternCallTest(QueryEvaluationHint hint) { |
657 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 657 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
658 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | 658 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); |
659 | var personView = new KeyOnlyRelationView<>(person); | 659 | var personView = new KeyOnlyView<>(person); |
660 | var friendMustView = new FilteredRelationView<>(friend, "must", TruthValue::must); | 660 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); |
661 | 661 | ||
662 | var p1 = Variable.of("p1"); | 662 | var p1 = Variable.of("p1"); |
663 | var p2 = Variable.of("p2"); | 663 | var p2 = Variable.of("p2"); |
@@ -720,8 +720,8 @@ class QueryTest { | |||
720 | void assumeTest(QueryEvaluationHint hint) { | 720 | void assumeTest(QueryEvaluationHint hint) { |
721 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 721 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
722 | var age = new Symbol<>("age", 1, Integer.class, null); | 722 | var age = new Symbol<>("age", 1, Integer.class, null); |
723 | var personView = new KeyOnlyRelationView<>(person); | 723 | var personView = new KeyOnlyView<>(person); |
724 | var ageView = new FunctionalRelationView<>(age); | 724 | var ageView = new FunctionView<>(age); |
725 | 725 | ||
726 | var p1 = Variable.of("p1"); | 726 | var p1 = Variable.of("p1"); |
727 | var x = Variable.of("x", Integer.class); | 727 | var x = Variable.of("x", Integer.class); |
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java index 07b799ac..bd6b6b81 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java | |||
@@ -12,9 +12,9 @@ import tools.refinery.store.model.ModelStore; | |||
12 | import tools.refinery.store.query.ModelQuery; | 12 | import tools.refinery.store.query.ModelQuery; |
13 | import tools.refinery.store.query.dnf.Query; | 13 | import tools.refinery.store.query.dnf.Query; |
14 | import tools.refinery.store.query.term.Variable; | 14 | import tools.refinery.store.query.term.Variable; |
15 | import tools.refinery.store.query.view.FilteredRelationView; | 15 | import tools.refinery.store.query.view.FilteredView; |
16 | import tools.refinery.store.query.view.FunctionalRelationView; | 16 | import tools.refinery.store.query.view.FunctionView; |
17 | import tools.refinery.store.query.view.KeyOnlyRelationView; | 17 | import tools.refinery.store.query.view.KeyOnlyView; |
18 | import tools.refinery.store.representation.Symbol; | 18 | import tools.refinery.store.representation.Symbol; |
19 | import tools.refinery.store.tuple.Tuple; | 19 | import tools.refinery.store.tuple.Tuple; |
20 | 20 | ||
@@ -30,7 +30,7 @@ class QueryTransactionTest { | |||
30 | @Test | 30 | @Test |
31 | void flushTest() { | 31 | void flushTest() { |
32 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 32 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
33 | var personView = new KeyOnlyRelationView<>(person); | 33 | var personView = new KeyOnlyView<>(person); |
34 | 34 | ||
35 | var p1 = Variable.of("p1"); | 35 | var p1 = Variable.of("p1"); |
36 | var predicate = Query.builder("TypeConstraint") | 36 | var predicate = Query.builder("TypeConstraint") |
@@ -101,7 +101,7 @@ class QueryTransactionTest { | |||
101 | @Test | 101 | @Test |
102 | void localSearchTest() { | 102 | void localSearchTest() { |
103 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 103 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
104 | var personView = new KeyOnlyRelationView<>(person); | 104 | var personView = new KeyOnlyView<>(person); |
105 | 105 | ||
106 | var p1 = Variable.of("p1"); | 106 | var p1 = Variable.of("p1"); |
107 | var predicate = Query.builder("TypeConstraint") | 107 | var predicate = Query.builder("TypeConstraint") |
@@ -156,7 +156,7 @@ class QueryTransactionTest { | |||
156 | void unrelatedChangesTest() { | 156 | void unrelatedChangesTest() { |
157 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 157 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
158 | var asset = new Symbol<>("Asset", 1, Boolean.class, false); | 158 | var asset = new Symbol<>("Asset", 1, Boolean.class, false); |
159 | var personView = new KeyOnlyRelationView<>(person); | 159 | var personView = new KeyOnlyView<>(person); |
160 | 160 | ||
161 | var p1 = Variable.of("p1"); | 161 | var p1 = Variable.of("p1"); |
162 | var predicate = Query.builder("TypeConstraint") | 162 | var predicate = Query.builder("TypeConstraint") |
@@ -229,8 +229,8 @@ class QueryTransactionTest { | |||
229 | void tupleChangingChangeTest() { | 229 | void tupleChangingChangeTest() { |
230 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 230 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
231 | var age = new Symbol<>("age", 1, Integer.class, null); | 231 | var age = new Symbol<>("age", 1, Integer.class, null); |
232 | var personView = new KeyOnlyRelationView<>(person); | 232 | var personView = new KeyOnlyView<>(person); |
233 | var ageView = new FunctionalRelationView<>(age); | 233 | var ageView = new FunctionView<>(age); |
234 | 234 | ||
235 | var p1 = Variable.of("p1"); | 235 | var p1 = Variable.of("p1"); |
236 | var x = Variable.of("x", Integer.class); | 236 | var x = Variable.of("x", Integer.class); |
@@ -277,8 +277,8 @@ class QueryTransactionTest { | |||
277 | void tuplePreservingUnchangedTest() { | 277 | void tuplePreservingUnchangedTest() { |
278 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 278 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
279 | var age = new Symbol<>("age", 1, Integer.class, null); | 279 | var age = new Symbol<>("age", 1, Integer.class, null); |
280 | var personView = new KeyOnlyRelationView<>(person); | 280 | var personView = new KeyOnlyView<>(person); |
281 | var adultView = new FilteredRelationView<>(age, "adult", n -> n != null && n >= 18); | 281 | var adultView = new FilteredView<>(age, "adult", n -> n != null && n >= 18); |
282 | 282 | ||
283 | var p1 = Variable.of("p1"); | 283 | var p1 = Variable.of("p1"); |
284 | var x = Variable.of("x", Integer.class); | 284 | var x = Variable.of("x", Integer.class); |
@@ -324,7 +324,7 @@ class QueryTransactionTest { | |||
324 | @Test | 324 | @Test |
325 | void commitAfterFlushTest() { | 325 | void commitAfterFlushTest() { |
326 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 326 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
327 | var personView = new KeyOnlyRelationView<>(person); | 327 | var personView = new KeyOnlyView<>(person); |
328 | 328 | ||
329 | var p1 = Variable.of("p1"); | 329 | var p1 = Variable.of("p1"); |
330 | var predicate = Query.builder("TypeConstraint") | 330 | var predicate = Query.builder("TypeConstraint") |
@@ -382,7 +382,7 @@ class QueryTransactionTest { | |||
382 | @Test | 382 | @Test |
383 | void commitWithoutFlushTest() { | 383 | void commitWithoutFlushTest() { |
384 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 384 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
385 | var personView = new KeyOnlyRelationView<>(person); | 385 | var personView = new KeyOnlyView<>(person); |
386 | 386 | ||
387 | var p1 = Variable.of("p1"); | 387 | var p1 = Variable.of("p1"); |
388 | var predicate = Query.builder("TypeConstraint") | 388 | var predicate = Query.builder("TypeConstraint") |
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/ModelQueryStoreAdapter.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/ModelQueryStoreAdapter.java index 33318abc..f0a950a6 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/ModelQueryStoreAdapter.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/ModelQueryStoreAdapter.java | |||
@@ -8,12 +8,12 @@ package tools.refinery.store.query; | |||
8 | import tools.refinery.store.adapter.ModelStoreAdapter; | 8 | import tools.refinery.store.adapter.ModelStoreAdapter; |
9 | import tools.refinery.store.model.Model; | 9 | import tools.refinery.store.model.Model; |
10 | import tools.refinery.store.query.dnf.AnyQuery; | 10 | import tools.refinery.store.query.dnf.AnyQuery; |
11 | import tools.refinery.store.query.view.AnyRelationView; | 11 | import tools.refinery.store.query.view.AnySymbolView; |
12 | 12 | ||
13 | import java.util.Collection; | 13 | import java.util.Collection; |
14 | 14 | ||
15 | public interface ModelQueryStoreAdapter extends ModelStoreAdapter { | 15 | public interface ModelQueryStoreAdapter extends ModelStoreAdapter { |
16 | Collection<AnyRelationView> getRelationViews(); | 16 | Collection<AnySymbolView> getSymbolViews(); |
17 | 17 | ||
18 | Collection<AnyQuery> getQueries(); | 18 | Collection<AnyQuery> getQueries(); |
19 | 19 | ||
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/FunctionalRelationView.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/AbstractFunctionView.java index ab48386e..c0aa35bf 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/FunctionalRelationView.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/AbstractFunctionView.java | |||
@@ -7,7 +7,6 @@ package tools.refinery.store.query.view; | |||
7 | 7 | ||
8 | import tools.refinery.store.model.Model; | 8 | import tools.refinery.store.model.Model; |
9 | import tools.refinery.store.query.dnf.FunctionalDependency; | 9 | import tools.refinery.store.query.dnf.FunctionalDependency; |
10 | import tools.refinery.store.query.term.DataSort; | ||
11 | import tools.refinery.store.query.term.NodeSort; | 10 | import tools.refinery.store.query.term.NodeSort; |
12 | import tools.refinery.store.query.term.Sort; | 11 | import tools.refinery.store.query.term.Sort; |
13 | import tools.refinery.store.representation.Symbol; | 12 | import tools.refinery.store.representation.Symbol; |
@@ -20,19 +19,14 @@ import java.util.Set; | |||
20 | import java.util.stream.Collectors; | 19 | import java.util.stream.Collectors; |
21 | import java.util.stream.IntStream; | 20 | import java.util.stream.IntStream; |
22 | 21 | ||
23 | public final class FunctionalRelationView<T> extends RelationView<T> { | 22 | public abstract class AbstractFunctionView<T> extends SymbolView<T> { |
24 | private final T defaultValue; | 23 | private final T defaultValue; |
25 | 24 | ||
26 | public FunctionalRelationView(Symbol<T> symbol, String name) { | 25 | protected AbstractFunctionView(Symbol<T> symbol, String name) { |
27 | super(symbol, name); | 26 | super(symbol, name); |
28 | defaultValue = symbol.defaultValue(); | 27 | defaultValue = symbol.defaultValue(); |
29 | } | 28 | } |
30 | 29 | ||
31 | public FunctionalRelationView(Symbol<T> symbol) { | ||
32 | super(symbol); | ||
33 | defaultValue = symbol.defaultValue(); | ||
34 | } | ||
35 | |||
36 | @Override | 30 | @Override |
37 | public Set<FunctionalDependency<Integer>> getFunctionalDependencies() { | 31 | public Set<FunctionalDependency<Integer>> getFunctionalDependencies() { |
38 | var arity = getSymbol().arity(); | 32 | var arity = getSymbol().arity(); |
@@ -42,18 +36,28 @@ public final class FunctionalRelationView<T> extends RelationView<T> { | |||
42 | } | 36 | } |
43 | 37 | ||
44 | @Override | 38 | @Override |
45 | public Set<RelationViewImplication> getImpliedRelationViews() { | 39 | public Set<ViewImplication> getImpliedRelationViews() { |
46 | var symbol = getSymbol(); | 40 | var symbol = getSymbol(); |
47 | var impliedIndices = IntStream.range(0, symbol.arity()).boxed().toList(); | 41 | var impliedIndices = IntStream.range(0, symbol.arity()).boxed().toList(); |
48 | var keyOnlyRelationView = new KeyOnlyRelationView<>(symbol); | 42 | var keysView = new KeyOnlyView<>(symbol); |
49 | return Set.of(new RelationViewImplication(this, keyOnlyRelationView, impliedIndices)); | 43 | return Set.of(new ViewImplication(this, keysView, impliedIndices)); |
50 | } | 44 | } |
51 | 45 | ||
52 | @Override | 46 | @Override |
53 | public boolean filter(Tuple key, T value) { | 47 | public final boolean filter(Tuple key, T value) { |
54 | return !Objects.equals(defaultValue, value); | 48 | return !Objects.equals(defaultValue, value); |
55 | } | 49 | } |
56 | 50 | ||
51 | protected abstract Sort getForwardMappedValueSort(); | ||
52 | |||
53 | protected Object forwardMapValue(Tuple key, T value) { | ||
54 | return value; | ||
55 | } | ||
56 | |||
57 | protected boolean valueEquals(Tuple key, T value, Object otherForwardMappedValue) { | ||
58 | return Objects.equals(otherForwardMappedValue, forwardMapValue(key, value)); | ||
59 | } | ||
60 | |||
57 | @Override | 61 | @Override |
58 | public Object[] forwardMap(Tuple key, T value) { | 62 | public Object[] forwardMap(Tuple key, T value) { |
59 | int size = key.getSize(); | 63 | int size = key.getSize(); |
@@ -61,7 +65,7 @@ public final class FunctionalRelationView<T> extends RelationView<T> { | |||
61 | for (int i = 0; i < size; i++) { | 65 | for (int i = 0; i < size; i++) { |
62 | result[i] = Tuple.of(key.get(i)); | 66 | result[i] = Tuple.of(key.get(i)); |
63 | } | 67 | } |
64 | result[key.getSize()] = value; | 68 | result[key.getSize()] = forwardMapValue(key, value); |
65 | return result; | 69 | return result; |
66 | } | 70 | } |
67 | 71 | ||
@@ -69,13 +73,15 @@ public final class FunctionalRelationView<T> extends RelationView<T> { | |||
69 | public boolean get(Model model, Object[] tuple) { | 73 | public boolean get(Model model, Object[] tuple) { |
70 | int[] content = new int[tuple.length - 1]; | 74 | int[] content = new int[tuple.length - 1]; |
71 | for (int i = 0; i < tuple.length - 1; i++) { | 75 | for (int i = 0; i < tuple.length - 1; i++) { |
72 | content[i] = ((Tuple1) tuple[i]).value0(); | 76 | if (!(tuple[i] instanceof Tuple1 wrapper)) { |
77 | return false; | ||
78 | } | ||
79 | content[i] = wrapper.value0(); | ||
73 | } | 80 | } |
74 | Tuple key = Tuple.of(content); | 81 | Tuple key = Tuple.of(content); |
75 | @SuppressWarnings("unchecked") | 82 | var valueInTuple = tuple[tuple.length - 1]; |
76 | T valueInTuple = (T) tuple[tuple.length - 1]; | ||
77 | T valueInMap = model.getInterpretation(getSymbol()).get(key); | 83 | T valueInMap = model.getInterpretation(getSymbol()).get(key); |
78 | return valueInTuple.equals(valueInMap); | 84 | return valueEquals(key, valueInMap, valueInTuple); |
79 | } | 85 | } |
80 | 86 | ||
81 | @Override | 87 | @Override |
@@ -90,7 +96,7 @@ public final class FunctionalRelationView<T> extends RelationView<T> { | |||
90 | for (int i = 0; i < valueIndex; i++) { | 96 | for (int i = 0; i < valueIndex; i++) { |
91 | sorts[i] = NodeSort.INSTANCE; | 97 | sorts[i] = NodeSort.INSTANCE; |
92 | } | 98 | } |
93 | sorts[valueIndex] = new DataSort<>(getSymbol().valueType()); | 99 | sorts[valueIndex] = getForwardMappedValueSort(); |
94 | return List.of(sorts); | 100 | return List.of(sorts); |
95 | } | 101 | } |
96 | 102 | ||
@@ -99,7 +105,7 @@ public final class FunctionalRelationView<T> extends RelationView<T> { | |||
99 | if (this == o) return true; | 105 | if (this == o) return true; |
100 | if (o == null || getClass() != o.getClass()) return false; | 106 | if (o == null || getClass() != o.getClass()) return false; |
101 | if (!super.equals(o)) return false; | 107 | if (!super.equals(o)) return false; |
102 | FunctionalRelationView<?> that = (FunctionalRelationView<?>) o; | 108 | AbstractFunctionView<?> that = (AbstractFunctionView<?>) o; |
103 | return Objects.equals(defaultValue, that.defaultValue); | 109 | return Objects.equals(defaultValue, that.defaultValue); |
104 | } | 110 | } |
105 | 111 | ||
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/AnyRelationView.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/AnySymbolView.java index 9aa923af..90b27ebb 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/AnyRelationView.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/AnySymbolView.java | |||
@@ -12,7 +12,7 @@ import tools.refinery.store.query.Constraint; | |||
12 | 12 | ||
13 | import java.util.Set; | 13 | import java.util.Set; |
14 | 14 | ||
15 | public sealed interface AnyRelationView extends Constraint permits RelationView { | 15 | public sealed interface AnySymbolView extends Constraint permits SymbolView { |
16 | AnySymbol getSymbol(); | 16 | AnySymbol getSymbol(); |
17 | 17 | ||
18 | String getViewName(); | 18 | String getViewName(); |
@@ -21,7 +21,7 @@ public sealed interface AnyRelationView extends Constraint permits RelationView | |||
21 | return Set.of(); | 21 | return Set.of(); |
22 | } | 22 | } |
23 | 23 | ||
24 | default Set<RelationViewImplication> getImpliedRelationViews() { | 24 | default Set<ViewImplication> getImpliedRelationViews() { |
25 | return Set.of(); | 25 | return Set.of(); |
26 | } | 26 | } |
27 | 27 | ||
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/FilteredRelationView.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/FilteredView.java index 9717b2c1..922c7355 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/FilteredRelationView.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/FilteredView.java | |||
@@ -12,24 +12,24 @@ import java.util.Objects; | |||
12 | import java.util.function.BiPredicate; | 12 | import java.util.function.BiPredicate; |
13 | import java.util.function.Predicate; | 13 | import java.util.function.Predicate; |
14 | 14 | ||
15 | public class FilteredRelationView<T> extends TuplePreservingRelationView<T> { | 15 | public class FilteredView<T> extends TuplePreservingView<T> { |
16 | private final BiPredicate<Tuple, T> predicate; | 16 | private final BiPredicate<Tuple, T> predicate; |
17 | 17 | ||
18 | public FilteredRelationView(Symbol<T> symbol, String name, BiPredicate<Tuple, T> predicate) { | 18 | public FilteredView(Symbol<T> symbol, String name, BiPredicate<Tuple, T> predicate) { |
19 | super(symbol, name); | 19 | super(symbol, name); |
20 | this.predicate = predicate; | 20 | this.predicate = predicate; |
21 | } | 21 | } |
22 | 22 | ||
23 | public FilteredRelationView(Symbol<T> symbol, BiPredicate<Tuple, T> predicate) { | 23 | public FilteredView(Symbol<T> symbol, BiPredicate<Tuple, T> predicate) { |
24 | super(symbol); | 24 | super(symbol); |
25 | this.predicate = predicate; | 25 | this.predicate = predicate; |
26 | } | 26 | } |
27 | 27 | ||
28 | public FilteredRelationView(Symbol<T> symbol, String name, Predicate<T> predicate) { | 28 | public FilteredView(Symbol<T> symbol, String name, Predicate<T> predicate) { |
29 | this(symbol, name, (k, v) -> predicate.test(v)); | 29 | this(symbol, name, (k, v) -> predicate.test(v)); |
30 | } | 30 | } |
31 | 31 | ||
32 | public FilteredRelationView(Symbol<T> symbol, Predicate<T> predicate) { | 32 | public FilteredView(Symbol<T> symbol, Predicate<T> predicate) { |
33 | this(symbol, (k, v) -> predicate.test(v)); | 33 | this(symbol, (k, v) -> predicate.test(v)); |
34 | } | 34 | } |
35 | 35 | ||
@@ -43,7 +43,7 @@ public class FilteredRelationView<T> extends TuplePreservingRelationView<T> { | |||
43 | if (this == o) return true; | 43 | if (this == o) return true; |
44 | if (o == null || getClass() != o.getClass()) return false; | 44 | if (o == null || getClass() != o.getClass()) return false; |
45 | if (!super.equals(o)) return false; | 45 | if (!super.equals(o)) return false; |
46 | FilteredRelationView<?> that = (FilteredRelationView<?>) o; | 46 | FilteredView<?> that = (FilteredView<?>) o; |
47 | return Objects.equals(predicate, that.predicate); | 47 | return Objects.equals(predicate, that.predicate); |
48 | } | 48 | } |
49 | 49 | ||
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/ForbiddenRelationView.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/ForbiddenView.java index c19d9282..26b717ee 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/ForbiddenRelationView.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/ForbiddenView.java | |||
@@ -9,8 +9,8 @@ import tools.refinery.store.representation.Symbol; | |||
9 | import tools.refinery.store.representation.TruthValue; | 9 | import tools.refinery.store.representation.TruthValue; |
10 | import tools.refinery.store.tuple.Tuple; | 10 | import tools.refinery.store.tuple.Tuple; |
11 | 11 | ||
12 | public class ForbiddenRelationView extends TuplePreservingRelationView<TruthValue> { | 12 | public class ForbiddenView extends TuplePreservingView<TruthValue> { |
13 | public ForbiddenRelationView(Symbol<TruthValue> symbol) { | 13 | public ForbiddenView(Symbol<TruthValue> symbol) { |
14 | super(symbol, "forbidden"); | 14 | super(symbol, "forbidden"); |
15 | } | 15 | } |
16 | 16 | ||
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/KeyOnlyRelationView.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/KeyOnlyView.java index 9553a0cc..7e86f6e4 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/KeyOnlyRelationView.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/KeyOnlyView.java | |||
@@ -10,12 +10,12 @@ import tools.refinery.store.tuple.Tuple; | |||
10 | 10 | ||
11 | import java.util.Objects; | 11 | import java.util.Objects; |
12 | 12 | ||
13 | public final class KeyOnlyRelationView<T> extends TuplePreservingRelationView<T> { | 13 | public final class KeyOnlyView<T> extends TuplePreservingView<T> { |
14 | public static final String VIEW_NAME = "key"; | 14 | public static final String VIEW_NAME = "key"; |
15 | 15 | ||
16 | private final T defaultValue; | 16 | private final T defaultValue; |
17 | 17 | ||
18 | public KeyOnlyRelationView(Symbol<T> symbol) { | 18 | public KeyOnlyView(Symbol<T> symbol) { |
19 | super(symbol, VIEW_NAME); | 19 | super(symbol, VIEW_NAME); |
20 | defaultValue = symbol.defaultValue(); | 20 | defaultValue = symbol.defaultValue(); |
21 | } | 21 | } |
@@ -30,7 +30,7 @@ public final class KeyOnlyRelationView<T> extends TuplePreservingRelationView<T> | |||
30 | if (this == o) return true; | 30 | if (this == o) return true; |
31 | if (o == null || getClass() != o.getClass()) return false; | 31 | if (o == null || getClass() != o.getClass()) return false; |
32 | if (!super.equals(o)) return false; | 32 | if (!super.equals(o)) return false; |
33 | KeyOnlyRelationView<?> that = (KeyOnlyRelationView<?>) o; | 33 | KeyOnlyView<?> that = (KeyOnlyView<?>) o; |
34 | return Objects.equals(defaultValue, that.defaultValue); | 34 | return Objects.equals(defaultValue, that.defaultValue); |
35 | } | 35 | } |
36 | 36 | ||
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/MayRelationView.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/MayView.java index 60325f35..e75a8171 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/MayRelationView.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/MayView.java | |||
@@ -9,8 +9,8 @@ import tools.refinery.store.representation.Symbol; | |||
9 | import tools.refinery.store.representation.TruthValue; | 9 | import tools.refinery.store.representation.TruthValue; |
10 | import tools.refinery.store.tuple.Tuple; | 10 | import tools.refinery.store.tuple.Tuple; |
11 | 11 | ||
12 | public class MayRelationView extends TuplePreservingRelationView<TruthValue> { | 12 | public class MayView extends TuplePreservingView<TruthValue> { |
13 | public MayRelationView(Symbol<TruthValue> symbol) { | 13 | public MayView(Symbol<TruthValue> symbol) { |
14 | super(symbol, "may"); | 14 | super(symbol, "may"); |
15 | } | 15 | } |
16 | 16 | ||
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/MustRelationView.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/MustView.java index d7e7ae2e..a48f8045 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/MustRelationView.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/MustView.java | |||
@@ -9,8 +9,8 @@ import tools.refinery.store.representation.Symbol; | |||
9 | import tools.refinery.store.representation.TruthValue; | 9 | import tools.refinery.store.representation.TruthValue; |
10 | import tools.refinery.store.tuple.Tuple; | 10 | import tools.refinery.store.tuple.Tuple; |
11 | 11 | ||
12 | public class MustRelationView extends TuplePreservingRelationView<TruthValue> { | 12 | public class MustView extends TuplePreservingView<TruthValue> { |
13 | public MustRelationView(Symbol<TruthValue> symbol) { | 13 | public MustView(Symbol<TruthValue> symbol) { |
14 | super(symbol, "must"); | 14 | super(symbol, "must"); |
15 | } | 15 | } |
16 | 16 | ||
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/RelationViewImplication.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/RelationViewImplication.java deleted file mode 100644 index c54cce2f..00000000 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/RelationViewImplication.java +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.store.query.view; | ||
7 | |||
8 | import java.util.List; | ||
9 | |||
10 | public record RelationViewImplication(AnyRelationView implyingRelationView, AnyRelationView impliedRelationView, | ||
11 | List<Integer> impliedIndices) { | ||
12 | public RelationViewImplication { | ||
13 | if (impliedIndices.size() != impliedRelationView.arity()) { | ||
14 | throw new IllegalArgumentException("Expected %d implied indices for %s, but %d are provided" | ||
15 | .formatted(impliedRelationView.arity(), impliedRelationView, impliedIndices.size())); | ||
16 | } | ||
17 | for (var index : impliedIndices) { | ||
18 | if (impliedRelationView.invalidIndex(index)) { | ||
19 | throw new IllegalArgumentException("%d is not a valid index for %s".formatted(index, | ||
20 | implyingRelationView)); | ||
21 | } | ||
22 | } | ||
23 | } | ||
24 | } | ||
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/RelationView.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/SymbolView.java index fd4f47b4..267a99d3 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/RelationView.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/SymbolView.java | |||
@@ -19,17 +19,17 @@ import java.util.UUID; | |||
19 | * @param <T> | 19 | * @param <T> |
20 | * @author Oszkar Semerath | 20 | * @author Oszkar Semerath |
21 | */ | 21 | */ |
22 | public abstract non-sealed class RelationView<T> implements AnyRelationView { | 22 | public abstract non-sealed class SymbolView<T> implements AnySymbolView { |
23 | private final Symbol<T> symbol; | 23 | private final Symbol<T> symbol; |
24 | 24 | ||
25 | private final String viewName; | 25 | private final String viewName; |
26 | 26 | ||
27 | protected RelationView(Symbol<T> symbol, String viewName) { | 27 | protected SymbolView(Symbol<T> symbol, String viewName) { |
28 | this.symbol = symbol; | 28 | this.symbol = symbol; |
29 | this.viewName = viewName; | 29 | this.viewName = viewName; |
30 | } | 30 | } |
31 | 31 | ||
32 | protected RelationView(Symbol<T> representation) { | 32 | protected SymbolView(Symbol<T> representation) { |
33 | this(representation, UUID.randomUUID().toString()); | 33 | this(representation, UUID.randomUUID().toString()); |
34 | } | 34 | } |
35 | 35 | ||
@@ -71,7 +71,7 @@ public abstract non-sealed class RelationView<T> implements AnyRelationView { | |||
71 | public boolean equals(Object o) { | 71 | public boolean equals(Object o) { |
72 | if (this == o) return true; | 72 | if (this == o) return true; |
73 | if (o == null || getClass() != o.getClass()) return false; | 73 | if (o == null || getClass() != o.getClass()) return false; |
74 | RelationView<?> that = (RelationView<?>) o; | 74 | SymbolView<?> that = (SymbolView<?>) o; |
75 | return Objects.equals(symbol, that.symbol) && Objects.equals(viewName, that.viewName); | 75 | return Objects.equals(symbol, that.symbol) && Objects.equals(viewName, that.viewName); |
76 | } | 76 | } |
77 | 77 | ||
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/TuplePreservingRelationView.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/TuplePreservingView.java index e6e54aa1..19862e3a 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/TuplePreservingRelationView.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/TuplePreservingView.java | |||
@@ -15,12 +15,12 @@ import tools.refinery.store.representation.Symbol; | |||
15 | import java.util.Arrays; | 15 | import java.util.Arrays; |
16 | import java.util.List; | 16 | import java.util.List; |
17 | 17 | ||
18 | public abstract class TuplePreservingRelationView<T> extends RelationView<T> { | 18 | public abstract class TuplePreservingView<T> extends SymbolView<T> { |
19 | protected TuplePreservingRelationView(Symbol<T> symbol, String name) { | 19 | protected TuplePreservingView(Symbol<T> symbol, String name) { |
20 | super(symbol, name); | 20 | super(symbol, name); |
21 | } | 21 | } |
22 | 22 | ||
23 | protected TuplePreservingRelationView(Symbol<T> symbol) { | 23 | protected TuplePreservingView(Symbol<T> symbol) { |
24 | super(symbol); | 24 | super(symbol); |
25 | } | 25 | } |
26 | 26 | ||
@@ -41,7 +41,10 @@ public abstract class TuplePreservingRelationView<T> extends RelationView<T> { | |||
41 | public boolean get(Model model, Object[] tuple) { | 41 | public boolean get(Model model, Object[] tuple) { |
42 | int[] content = new int[tuple.length]; | 42 | int[] content = new int[tuple.length]; |
43 | for (int i = 0; i < tuple.length; i++) { | 43 | for (int i = 0; i < tuple.length; i++) { |
44 | content[i] = ((Tuple1) tuple[i]).value0(); | 44 | if (!(tuple[i] instanceof Tuple1 wrapper)) { |
45 | return false; | ||
46 | } | ||
47 | content[i] = wrapper.value0(); | ||
45 | } | 48 | } |
46 | Tuple key = Tuple.of(content); | 49 | Tuple key = Tuple.of(content); |
47 | T value = model.getInterpretation(getSymbol()).get(key); | 50 | T value = model.getInterpretation(getSymbol()).get(key); |
diff --git a/subprojects/store-query/src/test/java/tools/refinery/store/query/DnfBuilderTest.java b/subprojects/store-query/src/test/java/tools/refinery/store/query/DnfBuilderTest.java index 70cd386b..152840f8 100644 --- a/subprojects/store-query/src/test/java/tools/refinery/store/query/DnfBuilderTest.java +++ b/subprojects/store-query/src/test/java/tools/refinery/store/query/DnfBuilderTest.java | |||
@@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test; | |||
9 | import tools.refinery.store.query.dnf.Dnf; | 9 | import tools.refinery.store.query.dnf.Dnf; |
10 | import tools.refinery.store.query.literal.BooleanLiteral; | 10 | import tools.refinery.store.query.literal.BooleanLiteral; |
11 | import tools.refinery.store.query.term.Variable; | 11 | import tools.refinery.store.query.term.Variable; |
12 | import tools.refinery.store.query.view.KeyOnlyRelationView; | 12 | import tools.refinery.store.query.view.KeyOnlyView; |
13 | import tools.refinery.store.representation.Symbol; | 13 | import tools.refinery.store.representation.Symbol; |
14 | 14 | ||
15 | import static org.hamcrest.MatcherAssert.assertThat; | 15 | import static org.hamcrest.MatcherAssert.assertThat; |
@@ -22,7 +22,7 @@ class DnfBuilderTest { | |||
22 | var p = Variable.of("p"); | 22 | var p = Variable.of("p"); |
23 | var q = Variable.of("q"); | 23 | var q = Variable.of("q"); |
24 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 24 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
25 | var friendView = new KeyOnlyRelationView<>(friend); | 25 | var friendView = new KeyOnlyView<>(friend); |
26 | 26 | ||
27 | var actual = Dnf.builder() | 27 | var actual = Dnf.builder() |
28 | .parameters(p, q) | 28 | .parameters(p, q) |
@@ -38,7 +38,7 @@ class DnfBuilderTest { | |||
38 | var p = Variable.of("p"); | 38 | var p = Variable.of("p"); |
39 | var q = Variable.of("q"); | 39 | var q = Variable.of("q"); |
40 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 40 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
41 | var friendView = new KeyOnlyRelationView<>(friend); | 41 | var friendView = new KeyOnlyView<>(friend); |
42 | 42 | ||
43 | var actual = Dnf.builder() | 43 | var actual = Dnf.builder() |
44 | .parameters(p, q) | 44 | .parameters(p, q) |
@@ -55,7 +55,7 @@ class DnfBuilderTest { | |||
55 | var p = Variable.of("p"); | 55 | var p = Variable.of("p"); |
56 | var q = Variable.of("q"); | 56 | var q = Variable.of("q"); |
57 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 57 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
58 | var friendView = new KeyOnlyRelationView<>(friend); | 58 | var friendView = new KeyOnlyView<>(friend); |
59 | 59 | ||
60 | var actual = Dnf.builder() | 60 | var actual = Dnf.builder() |
61 | .parameters(p, q) | 61 | .parameters(p, q) |
@@ -72,7 +72,7 @@ class DnfBuilderTest { | |||
72 | var p = Variable.of("p"); | 72 | var p = Variable.of("p"); |
73 | var q = Variable.of("q"); | 73 | var q = Variable.of("q"); |
74 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 74 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
75 | var friendView = new KeyOnlyRelationView<>(friend); | 75 | var friendView = new KeyOnlyView<>(friend); |
76 | 76 | ||
77 | var actual = Dnf.builder() | 77 | var actual = Dnf.builder() |
78 | .parameters(p, q) | 78 | .parameters(p, q) |
@@ -88,7 +88,7 @@ class DnfBuilderTest { | |||
88 | var p = Variable.of("p"); | 88 | var p = Variable.of("p"); |
89 | var q = Variable.of("q"); | 89 | var q = Variable.of("q"); |
90 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 90 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
91 | var friendView = new KeyOnlyRelationView<>(friend); | 91 | var friendView = new KeyOnlyView<>(friend); |
92 | var trueDnf = Dnf.builder().parameter(p).clause().build(); | 92 | var trueDnf = Dnf.builder().parameter(p).clause().build(); |
93 | 93 | ||
94 | var actual = Dnf.builder() | 94 | var actual = Dnf.builder() |
@@ -105,7 +105,7 @@ class DnfBuilderTest { | |||
105 | var p = Variable.of("p"); | 105 | var p = Variable.of("p"); |
106 | var q = Variable.of("q"); | 106 | var q = Variable.of("q"); |
107 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 107 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
108 | var friendView = new KeyOnlyRelationView<>(friend); | 108 | var friendView = new KeyOnlyView<>(friend); |
109 | var falseDnf = Dnf.builder().parameter(p).build(); | 109 | var falseDnf = Dnf.builder().parameter(p).build(); |
110 | 110 | ||
111 | var actual = Dnf.builder() | 111 | var actual = Dnf.builder() |
@@ -123,7 +123,7 @@ class DnfBuilderTest { | |||
123 | var p = Variable.of("p"); | 123 | var p = Variable.of("p"); |
124 | var q = Variable.of("q"); | 124 | var q = Variable.of("q"); |
125 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 125 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
126 | var friendView = new KeyOnlyRelationView<>(friend); | 126 | var friendView = new KeyOnlyView<>(friend); |
127 | var trueDnf = Dnf.builder().parameter(p).clause().build(); | 127 | var trueDnf = Dnf.builder().parameter(p).clause().build(); |
128 | 128 | ||
129 | var actual = Dnf.builder() | 129 | var actual = Dnf.builder() |
@@ -141,7 +141,7 @@ class DnfBuilderTest { | |||
141 | var p = Variable.of("p"); | 141 | var p = Variable.of("p"); |
142 | var q = Variable.of("q"); | 142 | var q = Variable.of("q"); |
143 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 143 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
144 | var friendView = new KeyOnlyRelationView<>(friend); | 144 | var friendView = new KeyOnlyView<>(friend); |
145 | var falseDnf = Dnf.builder().parameter(p).build(); | 145 | var falseDnf = Dnf.builder().parameter(p).build(); |
146 | 146 | ||
147 | var actual = Dnf.builder() | 147 | var actual = Dnf.builder() |
@@ -158,7 +158,7 @@ class DnfBuilderTest { | |||
158 | var p = Variable.of("p"); | 158 | var p = Variable.of("p"); |
159 | var q = Variable.of("q"); | 159 | var q = Variable.of("q"); |
160 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 160 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
161 | var friendView = new KeyOnlyRelationView<>(friend); | 161 | var friendView = new KeyOnlyView<>(friend); |
162 | var falseDnf = Dnf.builder().parameter(p).build(); | 162 | var falseDnf = Dnf.builder().parameter(p).build(); |
163 | 163 | ||
164 | var actual = Dnf.builder() | 164 | var actual = Dnf.builder() |
@@ -175,7 +175,7 @@ class DnfBuilderTest { | |||
175 | var p = Variable.of("p"); | 175 | var p = Variable.of("p"); |
176 | var q = Variable.of("q"); | 176 | var q = Variable.of("q"); |
177 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 177 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
178 | var friendView = new KeyOnlyRelationView<>(friend); | 178 | var friendView = new KeyOnlyView<>(friend); |
179 | var trueDnf = Dnf.builder().parameter(p).clause().build(); | 179 | var trueDnf = Dnf.builder().parameter(p).clause().build(); |
180 | 180 | ||
181 | var actual = Dnf.builder() | 181 | var actual = Dnf.builder() |
@@ -193,7 +193,7 @@ class DnfBuilderTest { | |||
193 | var p = Variable.of("p"); | 193 | var p = Variable.of("p"); |
194 | var q = Variable.of("q"); | 194 | var q = Variable.of("q"); |
195 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 195 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
196 | var friendView = new KeyOnlyRelationView<>(friend); | 196 | var friendView = new KeyOnlyView<>(friend); |
197 | var falseDnf = Dnf.builder().parameter(p).build(); | 197 | var falseDnf = Dnf.builder().parameter(p).build(); |
198 | 198 | ||
199 | var actual = Dnf.builder() | 199 | var actual = Dnf.builder() |
@@ -211,7 +211,7 @@ class DnfBuilderTest { | |||
211 | var p = Variable.of("p"); | 211 | var p = Variable.of("p"); |
212 | var q = Variable.of("q"); | 212 | var q = Variable.of("q"); |
213 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 213 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
214 | var friendView = new KeyOnlyRelationView<>(friend); | 214 | var friendView = new KeyOnlyView<>(friend); |
215 | var trueDnf = Dnf.builder().parameter(p).clause().build(); | 215 | var trueDnf = Dnf.builder().parameter(p).clause().build(); |
216 | 216 | ||
217 | var actual = Dnf.builder() | 217 | var actual = Dnf.builder() |
diff --git a/subprojects/store-query/src/test/java/tools/refinery/store/query/DnfToDefinitionStringTest.java b/subprojects/store-query/src/test/java/tools/refinery/store/query/DnfToDefinitionStringTest.java index 7be57745..e89ab682 100644 --- a/subprojects/store-query/src/test/java/tools/refinery/store/query/DnfToDefinitionStringTest.java +++ b/subprojects/store-query/src/test/java/tools/refinery/store/query/DnfToDefinitionStringTest.java | |||
@@ -8,7 +8,7 @@ package tools.refinery.store.query; | |||
8 | import org.junit.jupiter.api.Test; | 8 | import org.junit.jupiter.api.Test; |
9 | import tools.refinery.store.query.dnf.Dnf; | 9 | import tools.refinery.store.query.dnf.Dnf; |
10 | import tools.refinery.store.query.term.Variable; | 10 | import tools.refinery.store.query.term.Variable; |
11 | import tools.refinery.store.query.view.KeyOnlyRelationView; | 11 | import tools.refinery.store.query.view.KeyOnlyView; |
12 | import tools.refinery.store.representation.Symbol; | 12 | import tools.refinery.store.representation.Symbol; |
13 | 13 | ||
14 | import static org.hamcrest.MatcherAssert.assertThat; | 14 | import static org.hamcrest.MatcherAssert.assertThat; |
@@ -53,7 +53,7 @@ class DnfToDefinitionStringTest { | |||
53 | var p = Variable.of("p"); | 53 | var p = Variable.of("p"); |
54 | var q = Variable.of("q"); | 54 | var q = Variable.of("q"); |
55 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 55 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
56 | var friendView = new KeyOnlyRelationView<>(friend); | 56 | var friendView = new KeyOnlyView<>(friend); |
57 | var dnf = Dnf.builder("Example").parameter(p).clause(friendView.call(p, q)).build(); | 57 | var dnf = Dnf.builder("Example").parameter(p).clause(friendView.call(p, q)).build(); |
58 | 58 | ||
59 | assertThat(dnf.toDefinitionString(), is(""" | 59 | assertThat(dnf.toDefinitionString(), is(""" |
@@ -67,7 +67,7 @@ class DnfToDefinitionStringTest { | |||
67 | var p = Variable.of("p"); | 67 | var p = Variable.of("p"); |
68 | var q = Variable.of("q"); | 68 | var q = Variable.of("q"); |
69 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 69 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
70 | var friendView = new KeyOnlyRelationView<>(friend); | 70 | var friendView = new KeyOnlyView<>(friend); |
71 | var dnf = Dnf.builder("Example").parameter(p).clause(not(friendView.call(p, q))).build(); | 71 | var dnf = Dnf.builder("Example").parameter(p).clause(not(friendView.call(p, q))).build(); |
72 | 72 | ||
73 | assertThat(dnf.toDefinitionString(), is(""" | 73 | assertThat(dnf.toDefinitionString(), is(""" |
@@ -81,7 +81,7 @@ class DnfToDefinitionStringTest { | |||
81 | var p = Variable.of("p"); | 81 | var p = Variable.of("p"); |
82 | var q = Variable.of("q"); | 82 | var q = Variable.of("q"); |
83 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 83 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
84 | var friendView = new KeyOnlyRelationView<>(friend); | 84 | var friendView = new KeyOnlyView<>(friend); |
85 | var dnf = Dnf.builder("Example").parameter(p).clause(friendView.callTransitive(p, q)).build(); | 85 | var dnf = Dnf.builder("Example").parameter(p).clause(friendView.callTransitive(p, q)).build(); |
86 | 86 | ||
87 | assertThat(dnf.toDefinitionString(), is(""" | 87 | assertThat(dnf.toDefinitionString(), is(""" |
@@ -95,7 +95,7 @@ class DnfToDefinitionStringTest { | |||
95 | var p = Variable.of("p"); | 95 | var p = Variable.of("p"); |
96 | var q = Variable.of("q"); | 96 | var q = Variable.of("q"); |
97 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 97 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
98 | var friendView = new KeyOnlyRelationView<>(friend); | 98 | var friendView = new KeyOnlyView<>(friend); |
99 | var dnf = Dnf.builder("Example").parameters(p, q).clause(friendView.call(p, q)).build(); | 99 | var dnf = Dnf.builder("Example").parameters(p, q).clause(friendView.call(p, q)).build(); |
100 | 100 | ||
101 | assertThat(dnf.toDefinitionString(), is(""" | 101 | assertThat(dnf.toDefinitionString(), is(""" |
@@ -109,9 +109,9 @@ class DnfToDefinitionStringTest { | |||
109 | var p = Variable.of("p"); | 109 | var p = Variable.of("p"); |
110 | var q = Variable.of("q"); | 110 | var q = Variable.of("q"); |
111 | var person = new Symbol<>("person", 1, Boolean.class, false); | 111 | var person = new Symbol<>("person", 1, Boolean.class, false); |
112 | var personView = new KeyOnlyRelationView<>(person); | 112 | var personView = new KeyOnlyView<>(person); |
113 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 113 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
114 | var friendView = new KeyOnlyRelationView<>(friend); | 114 | var friendView = new KeyOnlyView<>(friend); |
115 | var dnf = Dnf.builder("Example") | 115 | var dnf = Dnf.builder("Example") |
116 | .parameter(p) | 116 | .parameter(p) |
117 | .clause( | 117 | .clause( |
@@ -134,7 +134,7 @@ class DnfToDefinitionStringTest { | |||
134 | var p = Variable.of("p"); | 134 | var p = Variable.of("p"); |
135 | var q = Variable.of("q"); | 135 | var q = Variable.of("q"); |
136 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 136 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
137 | var friendView = new KeyOnlyRelationView<>(friend); | 137 | var friendView = new KeyOnlyView<>(friend); |
138 | var dnf = Dnf.builder("Example") | 138 | var dnf = Dnf.builder("Example") |
139 | .parameter(p) | 139 | .parameter(p) |
140 | .clause(friendView.call(p, q)) | 140 | .clause(friendView.call(p, q)) |
@@ -156,9 +156,9 @@ class DnfToDefinitionStringTest { | |||
156 | var r = Variable.of("r"); | 156 | var r = Variable.of("r"); |
157 | var s = Variable.of("s"); | 157 | var s = Variable.of("s"); |
158 | var person = new Symbol<>("person", 1, Boolean.class, false); | 158 | var person = new Symbol<>("person", 1, Boolean.class, false); |
159 | var personView = new KeyOnlyRelationView<>(person); | 159 | var personView = new KeyOnlyView<>(person); |
160 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 160 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
161 | var friendView = new KeyOnlyRelationView<>(friend); | 161 | var friendView = new KeyOnlyView<>(friend); |
162 | var called = Dnf.builder("Called").parameters(r, s).clause(friendView.call(r, s)).build(); | 162 | var called = Dnf.builder("Called").parameters(r, s).clause(friendView.call(r, s)).build(); |
163 | var dnf = Dnf.builder("Example") | 163 | var dnf = Dnf.builder("Example") |
164 | .parameter(p) | 164 | .parameter(p) |
diff --git a/subprojects/store-query/src/test/java/tools/refinery/store/query/tests/StructurallyEqualToTest.java b/subprojects/store-query/src/test/java/tools/refinery/store/query/tests/StructurallyEqualToTest.java index e292b3ab..a1407288 100644 --- a/subprojects/store-query/src/test/java/tools/refinery/store/query/tests/StructurallyEqualToTest.java +++ b/subprojects/store-query/src/test/java/tools/refinery/store/query/tests/StructurallyEqualToTest.java | |||
@@ -8,7 +8,7 @@ package tools.refinery.store.query.tests; | |||
8 | import org.junit.jupiter.api.Test; | 8 | import org.junit.jupiter.api.Test; |
9 | import tools.refinery.store.query.dnf.Dnf; | 9 | import tools.refinery.store.query.dnf.Dnf; |
10 | import tools.refinery.store.query.term.Variable; | 10 | import tools.refinery.store.query.term.Variable; |
11 | import tools.refinery.store.query.view.KeyOnlyRelationView; | 11 | import tools.refinery.store.query.view.KeyOnlyView; |
12 | import tools.refinery.store.representation.Symbol; | 12 | import tools.refinery.store.representation.Symbol; |
13 | 13 | ||
14 | import static org.hamcrest.CoreMatchers.containsString; | 14 | import static org.hamcrest.CoreMatchers.containsString; |
@@ -22,7 +22,7 @@ class StructurallyEqualToTest { | |||
22 | var p = Variable.of("p"); | 22 | var p = Variable.of("p"); |
23 | var q = Variable.of("q"); | 23 | var q = Variable.of("q"); |
24 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 24 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
25 | var personView = new KeyOnlyRelationView<>(person); | 25 | var personView = new KeyOnlyView<>(person); |
26 | 26 | ||
27 | var expected = Dnf.builder("Expected").parameters(q).clause(personView.call(q)).build(); | 27 | var expected = Dnf.builder("Expected").parameters(q).clause(personView.call(q)).build(); |
28 | var actual = Dnf.builder("Actual").parameters(p).clause(personView.call(p)).build(); | 28 | var actual = Dnf.builder("Actual").parameters(p).clause(personView.call(p)).build(); |
@@ -35,7 +35,7 @@ class StructurallyEqualToTest { | |||
35 | var p = Variable.of("p"); | 35 | var p = Variable.of("p"); |
36 | var q = Variable.of("q"); | 36 | var q = Variable.of("q"); |
37 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 37 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
38 | var personView = new KeyOnlyRelationView<>(person); | 38 | var personView = new KeyOnlyView<>(person); |
39 | 39 | ||
40 | var expected = Dnf.builder("Expected").parameters(q).clause(personView.call(q)).build(); | 40 | var expected = Dnf.builder("Expected").parameters(q).clause(personView.call(q)).build(); |
41 | var actual = Dnf.builder("Actual").parameters(p).clause(personView.call(q)).build(); | 41 | var actual = Dnf.builder("Actual").parameters(p).clause(personView.call(q)).build(); |
@@ -49,7 +49,7 @@ class StructurallyEqualToTest { | |||
49 | var p = Variable.of("p"); | 49 | var p = Variable.of("p"); |
50 | var q = Variable.of("q"); | 50 | var q = Variable.of("q"); |
51 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 51 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
52 | var personView = new KeyOnlyRelationView<>(person); | 52 | var personView = new KeyOnlyView<>(person); |
53 | 53 | ||
54 | var expected = Dnf.builder("Expected").parameters(q).clause( | 54 | var expected = Dnf.builder("Expected").parameters(q).clause( |
55 | Dnf.builder("Expected2").parameters(p).clause(personView.call(p)).build().call(q) | 55 | Dnf.builder("Expected2").parameters(p).clause(personView.call(p)).build().call(q) |
@@ -66,7 +66,7 @@ class StructurallyEqualToTest { | |||
66 | var p = Variable.of("p"); | 66 | var p = Variable.of("p"); |
67 | var q = Variable.of("q"); | 67 | var q = Variable.of("q"); |
68 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 68 | var person = new Symbol<>("Person", 1, Boolean.class, false); |
69 | var personView = new KeyOnlyRelationView<>(person); | 69 | var personView = new KeyOnlyView<>(person); |
70 | 70 | ||
71 | var expected = Dnf.builder("Expected").parameters(q).clause( | 71 | var expected = Dnf.builder("Expected").parameters(q).clause( |
72 | Dnf.builder("Expected2").parameters(p).clause(personView.call(p)).build().call(q) | 72 | Dnf.builder("Expected2").parameters(p).clause(personView.call(p)).build().call(q) |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredMayTypeRelationView.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredMayTypeView.java index aea0a4b9..ce2d6ff3 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredMayTypeRelationView.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredMayTypeView.java | |||
@@ -6,13 +6,13 @@ | |||
6 | package tools.refinery.store.reasoning.translator.typehierarchy; | 6 | package tools.refinery.store.reasoning.translator.typehierarchy; |
7 | 7 | ||
8 | import tools.refinery.store.reasoning.representation.PartialRelation; | 8 | import tools.refinery.store.reasoning.representation.PartialRelation; |
9 | import tools.refinery.store.query.view.TuplePreservingRelationView; | 9 | import tools.refinery.store.query.view.TuplePreservingView; |
10 | import tools.refinery.store.tuple.Tuple; | 10 | import tools.refinery.store.tuple.Tuple; |
11 | 11 | ||
12 | class InferredMayTypeRelationView extends TuplePreservingRelationView<InferredType> { | 12 | class InferredMayTypeView extends TuplePreservingView<InferredType> { |
13 | private final PartialRelation type; | 13 | private final PartialRelation type; |
14 | 14 | ||
15 | InferredMayTypeRelationView(PartialRelation type) { | 15 | InferredMayTypeView(PartialRelation type) { |
16 | super(TypeHierarchyTranslationUnit.INFERRED_TYPE_SYMBOL, "%s#may".formatted(type)); | 16 | super(TypeHierarchyTranslationUnit.INFERRED_TYPE_SYMBOL, "%s#may".formatted(type)); |
17 | this.type = type; | 17 | this.type = type; |
18 | } | 18 | } |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredMustTypeRelationView.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredMustTypeView.java index 6c995e3a..beda1796 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredMustTypeRelationView.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredMustTypeView.java | |||
@@ -6,13 +6,13 @@ | |||
6 | package tools.refinery.store.reasoning.translator.typehierarchy; | 6 | package tools.refinery.store.reasoning.translator.typehierarchy; |
7 | 7 | ||
8 | import tools.refinery.store.reasoning.representation.PartialRelation; | 8 | import tools.refinery.store.reasoning.representation.PartialRelation; |
9 | import tools.refinery.store.query.view.TuplePreservingRelationView; | 9 | import tools.refinery.store.query.view.TuplePreservingView; |
10 | import tools.refinery.store.tuple.Tuple; | 10 | import tools.refinery.store.tuple.Tuple; |
11 | 11 | ||
12 | class InferredMustTypeRelationView extends TuplePreservingRelationView<InferredType> { | 12 | class InferredMustTypeView extends TuplePreservingView<InferredType> { |
13 | private final PartialRelation type; | 13 | private final PartialRelation type; |
14 | 14 | ||
15 | InferredMustTypeRelationView(PartialRelation type) { | 15 | InferredMustTypeView(PartialRelation type) { |
16 | super(TypeHierarchyTranslationUnit.INFERRED_TYPE_SYMBOL, "%s#must".formatted(type)); | 16 | super(TypeHierarchyTranslationUnit.INFERRED_TYPE_SYMBOL, "%s#must".formatted(type)); |
17 | this.type = type; | 17 | this.type = type; |
18 | } | 18 | } |