diff options
Diffstat (limited to 'subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery')
13 files changed, 58 insertions, 238 deletions
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/CheckEvaluator.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/CheckEvaluator.java index 5dde41be..ada154d4 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/CheckEvaluator.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/CheckEvaluator.java | |||
@@ -5,7 +5,7 @@ | |||
5 | */ | 5 | */ |
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.psystem.IValueProvider; | 8 | import tools.refinery.viatra.runtime.matchers.psystem.IValueProvider; |
9 | import tools.refinery.store.query.term.Term; | 9 | import tools.refinery.store.query.term.Term; |
10 | 10 | ||
11 | class CheckEvaluator extends TermEvaluator<Boolean> { | 11 | class CheckEvaluator extends TermEvaluator<Boolean> { |
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 af3bf32e..492bd054 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 | |||
@@ -5,24 +5,6 @@ | |||
5 | */ | 5 | */ |
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.backend.IQueryBackendFactory; | ||
9 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
10 | import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; | ||
11 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
12 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
13 | import org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.BoundAggregator; | ||
14 | import org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.*; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; | ||
24 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
25 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
26 | import tools.refinery.store.query.Constraint; | 8 | import tools.refinery.store.query.Constraint; |
27 | import tools.refinery.store.query.dnf.Dnf; | 9 | import tools.refinery.store.query.dnf.Dnf; |
28 | import tools.refinery.store.query.dnf.DnfClause; | 10 | import tools.refinery.store.query.dnf.DnfClause; |
@@ -34,6 +16,22 @@ import tools.refinery.store.query.term.StatelessAggregator; | |||
34 | import tools.refinery.store.query.term.Variable; | 16 | import tools.refinery.store.query.term.Variable; |
35 | import tools.refinery.store.query.view.AnySymbolView; | 17 | import tools.refinery.store.query.view.AnySymbolView; |
36 | import tools.refinery.store.util.CycleDetectingMapper; | 18 | import tools.refinery.store.util.CycleDetectingMapper; |
19 | import tools.refinery.viatra.runtime.matchers.backend.IQueryBackendFactory; | ||
20 | import tools.refinery.viatra.runtime.matchers.backend.QueryEvaluationHint; | ||
21 | import tools.refinery.viatra.runtime.matchers.context.IInputKey; | ||
22 | import tools.refinery.viatra.runtime.matchers.psystem.PBody; | ||
23 | import tools.refinery.viatra.runtime.matchers.psystem.PVariable; | ||
24 | import tools.refinery.viatra.runtime.matchers.psystem.aggregations.BoundAggregator; | ||
25 | import tools.refinery.viatra.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator; | ||
26 | import tools.refinery.viatra.runtime.matchers.psystem.annotations.PAnnotation; | ||
27 | import tools.refinery.viatra.runtime.matchers.psystem.basicdeferred.*; | ||
28 | import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.*; | ||
29 | import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.Connectivity; | ||
30 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameter; | ||
31 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameterDirection; | ||
32 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PQuery; | ||
33 | import tools.refinery.viatra.runtime.matchers.tuple.Tuple; | ||
34 | import tools.refinery.viatra.runtime.matchers.tuple.Tuples; | ||
37 | 35 | ||
38 | import java.util.ArrayList; | 36 | import java.util.ArrayList; |
39 | import java.util.HashMap; | 37 | import java.util.HashMap; |
@@ -42,7 +40,6 @@ import java.util.Map; | |||
42 | import java.util.function.Function; | 40 | import java.util.function.Function; |
43 | 41 | ||
44 | public class Dnf2PQuery { | 42 | public class Dnf2PQuery { |
45 | private static final Object P_CONSTRAINT_LOCK = new Object(); | ||
46 | private final CycleDetectingMapper<Dnf, RawPQuery> mapper = new CycleDetectingMapper<>(Dnf::name, | 43 | private final CycleDetectingMapper<Dnf, RawPQuery> mapper = new CycleDetectingMapper<>(Dnf::name, |
47 | this::doTranslate); | 44 | this::doTranslate); |
48 | private final QueryWrapperFactory wrapperFactory = new QueryWrapperFactory(this); | 45 | private final QueryWrapperFactory wrapperFactory = new QueryWrapperFactory(this); |
@@ -91,22 +88,17 @@ public class Dnf2PQuery { | |||
91 | pQuery.addAnnotation(functionalDependencyAnnotation); | 88 | pQuery.addAnnotation(functionalDependencyAnnotation); |
92 | } | 89 | } |
93 | 90 | ||
94 | // The constructor of {@link org.eclipse.viatra.query.runtime.matchers.psystem.BasePConstraint} mutates | 91 | for (DnfClause clause : dnfQuery.getClauses()) { |
95 | // global static state (<code>nextID</code>) without locking. Therefore, we need to synchronize before creating | 92 | PBody body = new PBody(pQuery); |
96 | // any query literals to avoid a data race. | 93 | List<ExportedParameter> parameterExports = new ArrayList<>(); |
97 | synchronized (P_CONSTRAINT_LOCK) { | 94 | for (var parameter : dnfQuery.getSymbolicParameters()) { |
98 | for (DnfClause clause : dnfQuery.getClauses()) { | 95 | PVariable pVar = body.getOrCreateVariableByName(parameter.getVariable().getUniqueName()); |
99 | PBody body = new PBody(pQuery); | 96 | parameterExports.add(new ExportedParameter(body, pVar, parameters.get(parameter))); |
100 | List<ExportedParameter> parameterExports = new ArrayList<>(); | 97 | } |
101 | for (var parameter : dnfQuery.getSymbolicParameters()) { | 98 | body.setSymbolicParameters(parameterExports); |
102 | PVariable pVar = body.getOrCreateVariableByName(parameter.getVariable().getUniqueName()); | 99 | pQuery.addBody(body); |
103 | parameterExports.add(new ExportedParameter(body, pVar, parameters.get(parameter))); | 100 | for (Literal literal : clause.literals()) { |
104 | } | 101 | translateLiteral(literal, body); |
105 | body.setSymbolicParameters(parameterExports); | ||
106 | pQuery.addBody(body); | ||
107 | for (Literal literal : clause.literals()) { | ||
108 | translateLiteral(literal, body); | ||
109 | } | ||
110 | } | 102 | } |
111 | } | 103 | } |
112 | 104 | ||
@@ -252,6 +244,10 @@ public class Dnf2PQuery { | |||
252 | private void translateRepresentativeElectionLiteral(RepresentativeElectionLiteral literal, PBody body) { | 244 | private void translateRepresentativeElectionLiteral(RepresentativeElectionLiteral literal, PBody body) { |
253 | var substitution = translateSubstitution(literal.getArguments(), body); | 245 | var substitution = translateSubstitution(literal.getArguments(), body); |
254 | var pattern = wrapConstraintWithIdentityArguments(literal.getTarget()); | 246 | var pattern = wrapConstraintWithIdentityArguments(literal.getTarget()); |
255 | new RepresentativeElectionConstraint(body, substitution, pattern, literal.getConnectivity()); | 247 | var connectivity = switch (literal.getConnectivity()) { |
248 | case WEAK -> Connectivity.WEAK; | ||
249 | case STRONG -> Connectivity.STRONG; | ||
250 | }; | ||
251 | new RepresentativeElectionConstraint(body, substitution, pattern, connectivity); | ||
256 | } | 252 | } |
257 | } | 253 | } |
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 502813e1..d21131e5 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 | |||
@@ -5,17 +5,17 @@ | |||
5 | */ | 5 | */ |
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.IInputKey; | 8 | import tools.refinery.viatra.runtime.matchers.context.IInputKey; |
9 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | 9 | import tools.refinery.viatra.runtime.matchers.psystem.PBody; |
10 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | 10 | import tools.refinery.viatra.runtime.matchers.psystem.PVariable; |
11 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | 11 | import tools.refinery.viatra.runtime.matchers.psystem.basicdeferred.ExportedParameter; |
12 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | 12 | import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.PositivePatternCall; |
13 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | 13 | import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.TypeConstraint; |
14 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | 14 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameter; |
15 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; | 15 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PQuery; |
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | 16 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PVisibility; |
17 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | 17 | import tools.refinery.viatra.runtime.matchers.tuple.Tuple; |
18 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | 18 | import tools.refinery.viatra.runtime.matchers.tuple.Tuples; |
19 | import tools.refinery.store.query.Constraint; | 19 | import tools.refinery.store.query.Constraint; |
20 | import tools.refinery.store.query.dnf.Dnf; | 20 | import tools.refinery.store.query.dnf.Dnf; |
21 | import tools.refinery.store.query.dnf.DnfUtils; | 21 | import tools.refinery.store.query.dnf.DnfUtils; |
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RawPQuery.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RawPQuery.java index 255738c5..06644bf2 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RawPQuery.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RawPQuery.java | |||
@@ -5,14 +5,14 @@ | |||
5 | */ | 5 | */ |
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.api.GenericQuerySpecification; | 8 | import tools.refinery.viatra.runtime.api.GenericQuerySpecification; |
9 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | 9 | import tools.refinery.viatra.runtime.api.ViatraQueryEngine; |
10 | import org.eclipse.viatra.query.runtime.api.scope.QueryScope; | 10 | import tools.refinery.viatra.runtime.api.scope.QueryScope; |
11 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | 11 | import tools.refinery.viatra.runtime.matchers.psystem.PBody; |
12 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | 12 | import tools.refinery.viatra.runtime.matchers.psystem.annotations.PAnnotation; |
13 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.BasePQuery; | 13 | import tools.refinery.viatra.runtime.matchers.psystem.queries.BasePQuery; |
14 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | 14 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameter; |
15 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | 15 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PVisibility; |
16 | import tools.refinery.store.query.viatra.internal.RelationalScope; | 16 | import tools.refinery.store.query.viatra.internal.RelationalScope; |
17 | import tools.refinery.store.query.viatra.internal.matcher.RawPatternMatcher; | 17 | import tools.refinery.store.query.viatra.internal.matcher.RawPatternMatcher; |
18 | 18 | ||
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RepresentativeElectionConstraint.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RepresentativeElectionConstraint.java deleted file mode 100644 index e146213e..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RepresentativeElectionConstraint.java +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.store.query.viatra.internal.pquery; | ||
7 | |||
8 | import org.eclipse.viatra.query.runtime.matchers.context.IQueryMetaContext; | ||
9 | import org.eclipse.viatra.query.runtime.matchers.psystem.*; | ||
10 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
11 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; | ||
12 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
13 | import tools.refinery.store.query.literal.Connectivity; | ||
14 | |||
15 | import java.util.Set; | ||
16 | |||
17 | public class RepresentativeElectionConstraint extends KeyedEnumerablePConstraint<PQuery> | ||
18 | implements IQueryReference, ITypeInfoProviderConstraint { | ||
19 | private final Connectivity connectivity; | ||
20 | |||
21 | public RepresentativeElectionConstraint(PBody pBody, Tuple variablesTuple, PQuery supplierKey, | ||
22 | Connectivity connectivity) { | ||
23 | super(pBody, variablesTuple, supplierKey); | ||
24 | this.connectivity = connectivity; | ||
25 | } | ||
26 | |||
27 | public Connectivity getConnectivity() { | ||
28 | return connectivity; | ||
29 | } | ||
30 | |||
31 | @Override | ||
32 | public PQuery getReferredQuery() { | ||
33 | return supplierKey; | ||
34 | } | ||
35 | |||
36 | @Override | ||
37 | public Set<TypeJudgement> getImpliedJudgements(IQueryMetaContext context) { | ||
38 | return PositivePatternCall.getTypesImpliedByCall(supplierKey, variablesTuple); | ||
39 | } | ||
40 | |||
41 | @Override | ||
42 | protected String keyToString() { | ||
43 | return supplierKey.getFullyQualifiedName() + "#representative"; | ||
44 | } | ||
45 | } | ||
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatefulMultisetAggregator.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatefulMultisetAggregator.java index 461416f7..ba99cf9a 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatefulMultisetAggregator.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatefulMultisetAggregator.java | |||
@@ -5,7 +5,7 @@ | |||
5 | */ | 5 | */ |
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.psystem.aggregations.IMultisetAggregationOperator; | 8 | import tools.refinery.viatra.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator; |
9 | import tools.refinery.store.query.term.StatefulAggregate; | 9 | import tools.refinery.store.query.term.StatefulAggregate; |
10 | import tools.refinery.store.query.term.StatefulAggregator; | 10 | import tools.refinery.store.query.term.StatefulAggregator; |
11 | 11 | ||
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatelessMultisetAggregator.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatelessMultisetAggregator.java index 49175d75..bf2c2f4f 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatelessMultisetAggregator.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/StatelessMultisetAggregator.java | |||
@@ -5,7 +5,7 @@ | |||
5 | */ | 5 | */ |
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.psystem.aggregations.IMultisetAggregationOperator; | 8 | import tools.refinery.viatra.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator; |
9 | import tools.refinery.store.query.term.StatelessAggregator; | 9 | import tools.refinery.store.query.term.StatelessAggregator; |
10 | 10 | ||
11 | import java.util.stream.Stream; | 11 | import java.util.stream.Stream; |
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/SymbolViewWrapper.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/SymbolViewWrapper.java index a777613e..a774404e 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/SymbolViewWrapper.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/SymbolViewWrapper.java | |||
@@ -5,7 +5,7 @@ | |||
5 | */ | 5 | */ |
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 tools.refinery.viatra.runtime.matchers.context.common.BaseInputKeyWrapper; |
9 | import tools.refinery.store.query.view.AnySymbolView; | 9 | import tools.refinery.store.query.view.AnySymbolView; |
10 | 10 | ||
11 | public class SymbolViewWrapper extends BaseInputKeyWrapper<AnySymbolView> { | 11 | public class SymbolViewWrapper extends BaseInputKeyWrapper<AnySymbolView> { |
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java index 1187f57a..5df861a6 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/TermEvaluator.java | |||
@@ -5,8 +5,8 @@ | |||
5 | */ | 5 | */ |
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.psystem.IExpressionEvaluator; | 8 | import tools.refinery.viatra.runtime.matchers.psystem.IExpressionEvaluator; |
9 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | 9 | import tools.refinery.viatra.runtime.matchers.psystem.IValueProvider; |
10 | import tools.refinery.store.query.term.Term; | 10 | import tools.refinery.store.query.term.Term; |
11 | import tools.refinery.store.query.term.Variable; | 11 | import tools.refinery.store.query.term.Variable; |
12 | 12 | ||
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/ValueProviderBasedValuation.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/ValueProviderBasedValuation.java index 62cb8b3a..b9ae8ab2 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/ValueProviderBasedValuation.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/ValueProviderBasedValuation.java | |||
@@ -5,7 +5,7 @@ | |||
5 | */ | 5 | */ |
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.psystem.IValueProvider; | 8 | import tools.refinery.viatra.runtime.matchers.psystem.IValueProvider; |
9 | import tools.refinery.store.query.term.DataVariable; | 9 | import tools.refinery.store.query.term.DataVariable; |
10 | import tools.refinery.store.query.valuation.Valuation; | 10 | import tools.refinery.store.query.valuation.Valuation; |
11 | 11 | ||
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyCopier.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyCopier.java deleted file mode 100644 index a833a37b..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyCopier.java +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.store.query.viatra.internal.pquery.rewriter; | ||
7 | |||
8 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
9 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint; | ||
10 | import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.IRewriterTraceCollector; | ||
11 | import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PBodyCopier; | ||
12 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
13 | import tools.refinery.store.query.viatra.internal.pquery.RepresentativeElectionConstraint; | ||
14 | |||
15 | public class RefineryPBodyCopier extends PBodyCopier { | ||
16 | public RefineryPBodyCopier(PBody body, IRewriterTraceCollector traceCollector) { | ||
17 | super(body, traceCollector); | ||
18 | } | ||
19 | |||
20 | @Override | ||
21 | protected void copyConstraint(PConstraint constraint) { | ||
22 | if (constraint instanceof RepresentativeElectionConstraint representativeElectionConstraint) { | ||
23 | copyRepresentativeElectionConstraint(representativeElectionConstraint); | ||
24 | } else { | ||
25 | super.copyConstraint(constraint); | ||
26 | } | ||
27 | } | ||
28 | |||
29 | private void copyRepresentativeElectionConstraint(RepresentativeElectionConstraint constraint) { | ||
30 | var mappedVariables = extractMappedVariables(constraint); | ||
31 | var variablesTuple = Tuples.flatTupleOf((Object[]) mappedVariables); | ||
32 | addTrace(constraint, new RepresentativeElectionConstraint(body, variablesTuple, constraint.getReferredQuery(), | ||
33 | constraint.getConnectivity())); | ||
34 | } | ||
35 | } | ||
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyNormalizer.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyNormalizer.java deleted file mode 100644 index ed85a843..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefineryPBodyNormalizer.java +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2004-2010 Gabor Bergmann and Daniel Varro | ||
3 | * Copyright (c) 2023 The Refinery Authors <https://refinery.tools/> | ||
4 | * This program and the accompanying materials are made available under the | ||
5 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
6 | * http://www.eclipse.org/legal/epl-v20.html. | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | package tools.refinery.store.query.viatra.internal.pquery.rewriter; | ||
10 | |||
11 | import org.eclipse.viatra.query.runtime.matchers.context.IQueryMetaContext; | ||
12 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
13 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PDisjunction; | ||
14 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PBodyCopier; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PBodyNormalizer; | ||
17 | |||
18 | import java.util.LinkedHashSet; | ||
19 | import java.util.Set; | ||
20 | |||
21 | public class RefineryPBodyNormalizer extends PBodyNormalizer { | ||
22 | public RefineryPBodyNormalizer(IQueryMetaContext context) { | ||
23 | super(context); | ||
24 | } | ||
25 | |||
26 | @Override | ||
27 | public PDisjunction rewrite(PDisjunction disjunction) { | ||
28 | Set<PBody> normalizedBodies = new LinkedHashSet<>(); | ||
29 | for (PBody body : disjunction.getBodies()) { | ||
30 | PBodyCopier copier = new RefineryPBodyCopier(body, getTraceCollector()); | ||
31 | PBody modifiedBody = copier.getCopiedBody(); | ||
32 | normalizeBody(modifiedBody); | ||
33 | normalizedBodies.add(modifiedBody); | ||
34 | modifiedBody.setStatus(PQuery.PQueryStatus.OK); | ||
35 | } | ||
36 | return new PDisjunction(normalizedBodies); | ||
37 | } | ||
38 | } | ||
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefinerySurrogateQueryRewriter.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefinerySurrogateQueryRewriter.java deleted file mode 100644 index dc288ba0..00000000 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/rewriter/RefinerySurrogateQueryRewriter.java +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2015, Zoltan Ujhelyi, Istvan Rath and Daniel Varro | ||
3 | * Copyright (c) 2023 The Refinery Authors <https://refinery.tools/> | ||
4 | * This program and the accompanying materials are made available under the | ||
5 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
6 | * http://www.eclipse.org/legal/epl-v20.html. | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | package tools.refinery.store.query.viatra.internal.pquery.rewriter; | ||
10 | |||
11 | import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; | ||
12 | import org.eclipse.viatra.query.runtime.matchers.context.surrogate.SurrogateQueryRegistry; | ||
13 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
14 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
16 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PDisjunction; | ||
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PBodyCopier; | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PDisjunctionRewriter; | ||
21 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
22 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
23 | |||
24 | import java.util.LinkedHashSet; | ||
25 | import java.util.Set; | ||
26 | |||
27 | public class RefinerySurrogateQueryRewriter extends PDisjunctionRewriter { | ||
28 | @Override | ||
29 | public PDisjunction rewrite(PDisjunction disjunction) { | ||
30 | Set<PBody> replacedBodies = new LinkedHashSet<>(); | ||
31 | for (PBody body : disjunction.getBodies()) { | ||
32 | PBodyCopier copier = new RefineryPBodyCopier(body, getTraceCollector()) { | ||
33 | |||
34 | @Override | ||
35 | protected void copyTypeConstraint(TypeConstraint typeConstraint) { | ||
36 | PVariable[] mappedVariables = extractMappedVariables(typeConstraint); | ||
37 | Tuple variablesTuple = Tuples.flatTupleOf((Object[]) mappedVariables); | ||
38 | final IInputKey supplierKey = typeConstraint.getSupplierKey(); | ||
39 | if (SurrogateQueryRegistry.instance().hasSurrogateQueryFQN(supplierKey)) { | ||
40 | PQuery surrogateQuery = SurrogateQueryRegistry.instance().getSurrogateQuery(supplierKey); | ||
41 | if (surrogateQuery == null) { | ||
42 | throw new IllegalStateException("Surrogate query for feature %s not found" | ||
43 | .formatted(supplierKey.getPrettyPrintableName())); | ||
44 | } | ||
45 | addTrace(typeConstraint, new PositivePatternCall(getCopiedBody(), variablesTuple, | ||
46 | surrogateQuery)); | ||
47 | } else { | ||
48 | addTrace(typeConstraint, new TypeConstraint(getCopiedBody(), variablesTuple, supplierKey)); | ||
49 | } | ||
50 | } | ||
51 | }; | ||
52 | PBody modifiedBody = copier.getCopiedBody(); | ||
53 | replacedBodies.add(modifiedBody); | ||
54 | modifiedBody.setStatus(PQuery.PQueryStatus.OK); | ||
55 | } | ||
56 | return new PDisjunction(replacedBodies); | ||
57 | } | ||
58 | } | ||