diff options
10 files changed, 109 insertions, 34 deletions
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/DummyBaseIndexer.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/DummyBaseIndexer.java index 4b311a64..29f0536c 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/DummyBaseIndexer.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/context/DummyBaseIndexer.java | |||
@@ -38,21 +38,21 @@ public class DummyBaseIndexer implements IBaseIndex { | |||
38 | 38 | ||
39 | @Override | 39 | @Override |
40 | public boolean addIndexingErrorListener(IIndexingErrorListener listener) { | 40 | public boolean addIndexingErrorListener(IIndexingErrorListener listener) { |
41 | return true; | 41 | return false; |
42 | } | 42 | } |
43 | 43 | ||
44 | @Override | 44 | @Override |
45 | public boolean removeIndexingErrorListener(IIndexingErrorListener listener) { | 45 | public boolean removeIndexingErrorListener(IIndexingErrorListener listener) { |
46 | return true; | 46 | return false; |
47 | } | 47 | } |
48 | 48 | ||
49 | @Override | 49 | @Override |
50 | public boolean addInstanceObserver(IInstanceObserver observer, Object observedObject) { | 50 | public boolean addInstanceObserver(IInstanceObserver observer, Object observedObject) { |
51 | return true; | 51 | return false; |
52 | } | 52 | } |
53 | 53 | ||
54 | @Override | 54 | @Override |
55 | public boolean removeInstanceObserver(IInstanceObserver observer, Object observedObject) { | 55 | public boolean removeInstanceObserver(IInstanceObserver observer, Object observedObject) { |
56 | return true; | 56 | return false; |
57 | } | 57 | } |
58 | } | 58 | } |
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 47b83634..81046b2a 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 | |||
@@ -26,6 +26,11 @@ public class RelationalQueryMetaContext extends AbstractQueryMetaContext { | |||
26 | } | 26 | } |
27 | 27 | ||
28 | @Override | 28 | @Override |
29 | public boolean canLeadOutOfScope(IInputKey key) { | ||
30 | return false; | ||
31 | } | ||
32 | |||
33 | @Override | ||
29 | public Collection<InputKeyImplication> getImplications(IInputKey implyingKey) { | 34 | public Collection<InputKeyImplication> getImplications(IInputKey implyingKey) { |
30 | ensureValidKey(implyingKey); | 35 | ensureValidKey(implyingKey); |
31 | return Set.of(); | 36 | return Set.of(); |
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 7375b240..9c1d966c 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 | |||
@@ -10,7 +10,6 @@ import tools.refinery.store.model.Model; | |||
10 | import tools.refinery.store.query.viatra.internal.pquery.RelationViewWrapper; | 10 | import tools.refinery.store.query.viatra.internal.pquery.RelationViewWrapper; |
11 | import tools.refinery.store.query.viatra.internal.update.ModelUpdateListener; | 11 | import tools.refinery.store.query.viatra.internal.update.ModelUpdateListener; |
12 | import tools.refinery.store.query.view.AnyRelationView; | 12 | import tools.refinery.store.query.view.AnyRelationView; |
13 | import tools.refinery.store.query.view.RelationView; | ||
14 | 13 | ||
15 | import java.lang.reflect.InvocationTargetException; | 14 | import java.lang.reflect.InvocationTargetException; |
16 | import java.util.Iterator; | 15 | import java.util.Iterator; |
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 eb815588..f2cb8d8d 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 | |||
@@ -27,6 +27,8 @@ import java.util.function.Function; | |||
27 | import java.util.stream.Collectors; | 27 | import java.util.stream.Collectors; |
28 | 28 | ||
29 | public class DNF2PQuery { | 29 | public class DNF2PQuery { |
30 | private static final Object P_CONSTRAINT_LOCK = new Object(); | ||
31 | |||
30 | private final Set<DNF> translating = new LinkedHashSet<>(); | 32 | private final Set<DNF> translating = new LinkedHashSet<>(); |
31 | 33 | ||
32 | private final Map<DNF, RawPQuery> dnf2PQueryMap = new HashMap<>(); | 34 | private final Map<DNF, RawPQuery> dnf2PQueryMap = new HashMap<>(); |
@@ -84,17 +86,22 @@ public class DNF2PQuery { | |||
84 | } | 86 | } |
85 | pQuery.setParameters(parameterList); | 87 | pQuery.setParameters(parameterList); |
86 | 88 | ||
87 | for (DNFAnd clause : dnfQuery.getClauses()) { | 89 | // The constructor of {@link org.eclipse.viatra.query.runtime.matchers.psystem.BasePConstraint} mutates |
88 | PBody body = new PBody(pQuery); | 90 | // global static state (<code>nextID</code>) without locking. Therefore, we need to synchronize before creating |
89 | List<ExportedParameter> symbolicParameters = new ArrayList<>(); | 91 | // any query constraints to avoid a data race. |
90 | for (var param : dnfQuery.getParameters()) { | 92 | synchronized (P_CONSTRAINT_LOCK) { |
91 | PVariable pVar = body.getOrCreateVariableByName(param.getUniqueName()); | 93 | for (DNFAnd clause : dnfQuery.getClauses()) { |
92 | symbolicParameters.add(new ExportedParameter(body, pVar, parameters.get(param))); | 94 | PBody body = new PBody(pQuery); |
93 | } | 95 | List<ExportedParameter> symbolicParameters = new ArrayList<>(); |
94 | body.setSymbolicParameters(symbolicParameters); | 96 | for (var param : dnfQuery.getParameters()) { |
95 | pQuery.addBody(body); | 97 | PVariable pVar = body.getOrCreateVariableByName(param.getUniqueName()); |
96 | for (DNFAtom constraint : clause.constraints()) { | 98 | symbolicParameters.add(new ExportedParameter(body, pVar, parameters.get(param))); |
97 | translateDNFAtom(constraint, body); | 99 | } |
100 | body.setSymbolicParameters(symbolicParameters); | ||
101 | pQuery.addBody(body); | ||
102 | for (DNFAtom constraint : clause.constraints()) { | ||
103 | translateDNFAtom(constraint, body); | ||
104 | } | ||
98 | } | 105 | } |
99 | } | 106 | } |
100 | 107 | ||
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/TupleChangingRelationViewUpdateListener.java index c17e826d..0d43eac1 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/TupleChangingRelationViewUpdateListener.java | |||
@@ -28,7 +28,7 @@ public class TupleChangingRelationViewUpdateListener<T> extends RelationViewUpda | |||
28 | } else { // fromValue disappears | 28 | } else { // fromValue disappears |
29 | processUpdate(Tuples.flatTupleOf(relationView.forwardMap(key, fromValue)), false); | 29 | processUpdate(Tuples.flatTupleOf(relationView.forwardMap(key, fromValue)), false); |
30 | } | 30 | } |
31 | } else if (toPresent) { // toValue disappears | 31 | } else if (toPresent) { // toValue appears |
32 | processUpdate(Tuples.flatTupleOf(relationView.forwardMap(key, toValue)), true); | 32 | processUpdate(Tuples.flatTupleOf(relationView.forwardMap(key, toValue)), true); |
33 | } | 33 | } |
34 | } | 34 | } |
diff --git a/subprojects/store/src/main/java/tools/refinery/store/partial/PartialInterpretation.java b/subprojects/store/src/main/java/tools/refinery/store/partial/PartialInterpretation.java new file mode 100644 index 00000000..7d367937 --- /dev/null +++ b/subprojects/store/src/main/java/tools/refinery/store/partial/PartialInterpretation.java | |||
@@ -0,0 +1,18 @@ | |||
1 | package tools.refinery.store.partial; | ||
2 | |||
3 | import tools.refinery.store.adapter.ModelAdapterBuilderFactory; | ||
4 | import tools.refinery.store.model.ModelStoreBuilder; | ||
5 | |||
6 | public final class PartialInterpretation extends ModelAdapterBuilderFactory<PartialModelAdapter, | ||
7 | PartialModelStoreAdapter, PartialModelAdapterBuilder> { | ||
8 | public static final PartialInterpretation ADAPTER = new PartialInterpretation(); | ||
9 | |||
10 | private PartialInterpretation() { | ||
11 | super(PartialModelAdapter.class, PartialModelStoreAdapter.class, PartialModelAdapterBuilder.class); | ||
12 | } | ||
13 | |||
14 | @Override | ||
15 | public PartialModelAdapterBuilder createBuilder(ModelStoreBuilder storeBuilder) { | ||
16 | return new PartialModelAdapterBuilder(storeBuilder); | ||
17 | } | ||
18 | } | ||
diff --git a/subprojects/store/src/main/java/tools/refinery/store/partial/PartialModelAdapter.java b/subprojects/store/src/main/java/tools/refinery/store/partial/PartialModelAdapter.java new file mode 100644 index 00000000..cdab5606 --- /dev/null +++ b/subprojects/store/src/main/java/tools/refinery/store/partial/PartialModelAdapter.java | |||
@@ -0,0 +1,24 @@ | |||
1 | package tools.refinery.store.partial; | ||
2 | |||
3 | import tools.refinery.store.adapter.ModelAdapter; | ||
4 | import tools.refinery.store.model.Model; | ||
5 | |||
6 | public class PartialModelAdapter implements ModelAdapter { | ||
7 | private final Model model; | ||
8 | private final PartialModelStoreAdapter storeAdapter; | ||
9 | |||
10 | PartialModelAdapter(Model model, PartialModelStoreAdapter storeAdapter) { | ||
11 | this.model = model; | ||
12 | this.storeAdapter = storeAdapter; | ||
13 | } | ||
14 | |||
15 | @Override | ||
16 | public Model getModel() { | ||
17 | return model; | ||
18 | } | ||
19 | |||
20 | @Override | ||
21 | public PartialModelStoreAdapter getStoreAdapter() { | ||
22 | return storeAdapter; | ||
23 | } | ||
24 | } | ||
diff --git a/subprojects/store/src/main/java/tools/refinery/store/partial/PartialModelAdapterBuilder.java b/subprojects/store/src/main/java/tools/refinery/store/partial/PartialModelAdapterBuilder.java new file mode 100644 index 00000000..0d4a32b9 --- /dev/null +++ b/subprojects/store/src/main/java/tools/refinery/store/partial/PartialModelAdapterBuilder.java | |||
@@ -0,0 +1,16 @@ | |||
1 | package tools.refinery.store.partial; | ||
2 | |||
3 | import tools.refinery.store.adapter.AbstractModelAdapterBuilder; | ||
4 | import tools.refinery.store.model.ModelStore; | ||
5 | import tools.refinery.store.model.ModelStoreBuilder; | ||
6 | |||
7 | public class PartialModelAdapterBuilder extends AbstractModelAdapterBuilder { | ||
8 | PartialModelAdapterBuilder(ModelStoreBuilder storeBuilder) { | ||
9 | super(storeBuilder); | ||
10 | } | ||
11 | |||
12 | @Override | ||
13 | public PartialModelStoreAdapter createStoreAdapter(ModelStore store) { | ||
14 | return null; | ||
15 | } | ||
16 | } | ||
diff --git a/subprojects/store/src/main/java/tools/refinery/store/partial/PartialModelStoreAdapter.java b/subprojects/store/src/main/java/tools/refinery/store/partial/PartialModelStoreAdapter.java new file mode 100644 index 00000000..d9432a7d --- /dev/null +++ b/subprojects/store/src/main/java/tools/refinery/store/partial/PartialModelStoreAdapter.java | |||
@@ -0,0 +1,23 @@ | |||
1 | package tools.refinery.store.partial; | ||
2 | |||
3 | import tools.refinery.store.adapter.ModelStoreAdapter; | ||
4 | import tools.refinery.store.model.Model; | ||
5 | import tools.refinery.store.model.ModelStore; | ||
6 | |||
7 | public class PartialModelStoreAdapter implements ModelStoreAdapter { | ||
8 | private final ModelStore store; | ||
9 | |||
10 | PartialModelStoreAdapter(ModelStore store) { | ||
11 | this.store = store; | ||
12 | } | ||
13 | |||
14 | @Override | ||
15 | public ModelStore getStore() { | ||
16 | return store; | ||
17 | } | ||
18 | |||
19 | @Override | ||
20 | public PartialModelAdapter createModelAdapter(Model model) { | ||
21 | return new PartialModelAdapter(model, this); | ||
22 | } | ||
23 | } | ||
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/ModalRelation.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/ModalRelation.java deleted file mode 100644 index c2ca1fdb..00000000 --- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/ModalRelation.java +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | package tools.refinery.store.query.atom; | ||
2 | |||
3 | import tools.refinery.store.representation.SymbolLike; | ||
4 | import tools.refinery.store.representation.Symbol; | ||
5 | import tools.refinery.store.representation.TruthValue; | ||
6 | |||
7 | public record ModalRelation(Modality modality, Symbol<TruthValue> relation) implements SymbolLike { | ||
8 | @Override | ||
9 | public String name() { | ||
10 | return "%s %s".formatted(modality, relation); | ||
11 | } | ||
12 | |||
13 | @Override | ||
14 | public int arity() { | ||
15 | return relation.arity(); | ||
16 | } | ||
17 | } | ||