diff options
Diffstat (limited to 'subprojects/store-query-viatra/src/main/java')
-rw-r--r-- | subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java | 14 | ||||
-rw-r--r-- | subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java | 6 | ||||
-rw-r--r-- | subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java | 16 | ||||
-rw-r--r-- | subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryStoreAdapterImpl.java | 10 | ||||
-rw-r--r-- | subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java (renamed from subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/DNF2PQuery.java) | 86 |
5 files changed, 66 insertions, 66 deletions
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java index efc6146c..24aa52e2 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java | |||
@@ -4,7 +4,7 @@ import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions; | |||
4 | import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; | 4 | import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; |
5 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | 5 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; |
6 | import tools.refinery.store.model.ModelStore; | 6 | import tools.refinery.store.model.ModelStore; |
7 | import tools.refinery.store.query.DNF; | 7 | import tools.refinery.store.query.Dnf; |
8 | import tools.refinery.store.query.ModelQueryBuilder; | 8 | import tools.refinery.store.query.ModelQueryBuilder; |
9 | 9 | ||
10 | import java.util.Collection; | 10 | import java.util.Collection; |
@@ -23,25 +23,25 @@ public interface ViatraModelQueryBuilder extends ModelQueryBuilder { | |||
23 | ViatraModelQueryBuilder searchBackend(IQueryBackendFactory queryBackendFactory); | 23 | ViatraModelQueryBuilder searchBackend(IQueryBackendFactory queryBackendFactory); |
24 | 24 | ||
25 | @Override | 25 | @Override |
26 | default ViatraModelQueryBuilder queries(DNF... queries) { | 26 | default ViatraModelQueryBuilder queries(Dnf... queries) { |
27 | ModelQueryBuilder.super.queries(queries); | 27 | ModelQueryBuilder.super.queries(queries); |
28 | return this; | 28 | return this; |
29 | } | 29 | } |
30 | 30 | ||
31 | @Override | 31 | @Override |
32 | default ViatraModelQueryBuilder queries(Collection<DNF> queries) { | 32 | default ViatraModelQueryBuilder queries(Collection<Dnf> queries) { |
33 | ModelQueryBuilder.super.queries(queries); | 33 | ModelQueryBuilder.super.queries(queries); |
34 | return this; | 34 | return this; |
35 | } | 35 | } |
36 | 36 | ||
37 | @Override | 37 | @Override |
38 | ViatraModelQueryBuilder query(DNF query); | 38 | ViatraModelQueryBuilder query(Dnf query); |
39 | 39 | ||
40 | ViatraModelQueryBuilder query(DNF query, QueryEvaluationHint queryEvaluationHint); | 40 | ViatraModelQueryBuilder query(Dnf query, QueryEvaluationHint queryEvaluationHint); |
41 | 41 | ||
42 | ViatraModelQueryBuilder computeHint(Function<DNF, QueryEvaluationHint> computeHint); | 42 | ViatraModelQueryBuilder computeHint(Function<Dnf, QueryEvaluationHint> computeHint); |
43 | 43 | ||
44 | ViatraModelQueryBuilder hint(DNF dnf, QueryEvaluationHint queryEvaluationHint); | 44 | ViatraModelQueryBuilder hint(Dnf dnf, QueryEvaluationHint queryEvaluationHint); |
45 | 45 | ||
46 | @Override | 46 | @Override |
47 | ViatraModelQueryStoreAdapter createStoreAdapter(ModelStore store); | 47 | ViatraModelQueryStoreAdapter createStoreAdapter(ModelStore store); |
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java index 039f46fa..e5d8e2f6 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java | |||
@@ -7,7 +7,7 @@ import org.eclipse.viatra.query.runtime.internal.apiimpl.ViatraQueryEngineImpl; | |||
7 | import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackend; | 7 | import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackend; |
8 | import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; | 8 | import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; |
9 | import tools.refinery.store.model.Model; | 9 | import tools.refinery.store.model.Model; |
10 | import tools.refinery.store.query.DNF; | 10 | import tools.refinery.store.query.Dnf; |
11 | import tools.refinery.store.query.ResultSet; | 11 | import tools.refinery.store.query.ResultSet; |
12 | import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; | 12 | import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; |
13 | 13 | ||
@@ -27,7 +27,7 @@ public class ViatraModelQueryAdapterImpl implements ViatraModelQueryAdapter { | |||
27 | private final ViatraQueryEngineImpl queryEngine; | 27 | private final ViatraQueryEngineImpl queryEngine; |
28 | private final MethodHandle setUpdatePropagationDelayedHandle; | 28 | private final MethodHandle setUpdatePropagationDelayedHandle; |
29 | private final MethodHandle getQueryBackendsHandle; | 29 | private final MethodHandle getQueryBackendsHandle; |
30 | private final Map<DNF, ResultSet> resultSets; | 30 | private final Map<Dnf, ResultSet> resultSets; |
31 | private boolean pendingChanges; | 31 | private boolean pendingChanges; |
32 | 32 | ||
33 | ViatraModelQueryAdapterImpl(Model model, ViatraModelQueryStoreAdapterImpl storeAdapter) { | 33 | ViatraModelQueryAdapterImpl(Model model, ViatraModelQueryStoreAdapterImpl storeAdapter) { |
@@ -95,7 +95,7 @@ public class ViatraModelQueryAdapterImpl implements ViatraModelQueryAdapter { | |||
95 | } | 95 | } |
96 | 96 | ||
97 | @Override | 97 | @Override |
98 | public ResultSet getResultSet(DNF query) { | 98 | public ResultSet getResultSet(Dnf query) { |
99 | var resultSet = resultSets.get(query); | 99 | var resultSet = resultSets.get(query); |
100 | if (resultSet == null) { | 100 | if (resultSet == null) { |
101 | throw new IllegalArgumentException("No matcher for query %s in model".formatted(query.name())); | 101 | throw new IllegalArgumentException("No matcher for query %s in model".formatted(query.name())); |
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 9f1e55b1..af20033a 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 | |||
@@ -9,9 +9,9 @@ import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory; | |||
9 | import tools.refinery.store.adapter.AbstractModelAdapterBuilder; | 9 | import tools.refinery.store.adapter.AbstractModelAdapterBuilder; |
10 | import tools.refinery.store.model.ModelStore; | 10 | import tools.refinery.store.model.ModelStore; |
11 | import tools.refinery.store.model.ModelStoreBuilder; | 11 | import tools.refinery.store.model.ModelStoreBuilder; |
12 | import tools.refinery.store.query.DNF; | 12 | import tools.refinery.store.query.Dnf; |
13 | import tools.refinery.store.query.viatra.ViatraModelQueryBuilder; | 13 | import tools.refinery.store.query.viatra.ViatraModelQueryBuilder; |
14 | import tools.refinery.store.query.viatra.internal.pquery.DNF2PQuery; | 14 | import tools.refinery.store.query.viatra.internal.pquery.Dnf2PQuery; |
15 | import tools.refinery.store.query.viatra.internal.pquery.RawPatternMatcher; | 15 | import tools.refinery.store.query.viatra.internal.pquery.RawPatternMatcher; |
16 | 16 | ||
17 | import java.util.Collections; | 17 | import java.util.Collections; |
@@ -21,8 +21,8 @@ import java.util.function.Function; | |||
21 | 21 | ||
22 | public class ViatraModelQueryBuilderImpl extends AbstractModelAdapterBuilder implements ViatraModelQueryBuilder { | 22 | public class ViatraModelQueryBuilderImpl extends AbstractModelAdapterBuilder implements ViatraModelQueryBuilder { |
23 | private ViatraQueryEngineOptions.Builder engineOptionsBuilder; | 23 | private ViatraQueryEngineOptions.Builder engineOptionsBuilder; |
24 | private final DNF2PQuery dnf2PQuery = new DNF2PQuery(); | 24 | private final Dnf2PQuery dnf2PQuery = new Dnf2PQuery(); |
25 | private final Map<DNF, IQuerySpecification<RawPatternMatcher>> querySpecifications = new LinkedHashMap<>(); | 25 | private final Map<Dnf, IQuerySpecification<RawPatternMatcher>> querySpecifications = new LinkedHashMap<>(); |
26 | 26 | ||
27 | public ViatraModelQueryBuilderImpl(ModelStoreBuilder storeBuilder) { | 27 | public ViatraModelQueryBuilderImpl(ModelStoreBuilder storeBuilder) { |
28 | super(storeBuilder); | 28 | super(storeBuilder); |
@@ -63,7 +63,7 @@ public class ViatraModelQueryBuilderImpl extends AbstractModelAdapterBuilder imp | |||
63 | } | 63 | } |
64 | 64 | ||
65 | @Override | 65 | @Override |
66 | public ViatraModelQueryBuilder query(DNF query) { | 66 | public ViatraModelQueryBuilder query(Dnf query) { |
67 | if (querySpecifications.containsKey(query)) { | 67 | if (querySpecifications.containsKey(query)) { |
68 | throw new IllegalArgumentException("%s was already added to the query engine".formatted(query.name())); | 68 | throw new IllegalArgumentException("%s was already added to the query engine".formatted(query.name())); |
69 | } | 69 | } |
@@ -73,20 +73,20 @@ public class ViatraModelQueryBuilderImpl extends AbstractModelAdapterBuilder imp | |||
73 | } | 73 | } |
74 | 74 | ||
75 | @Override | 75 | @Override |
76 | public ViatraModelQueryBuilder query(DNF query, QueryEvaluationHint queryEvaluationHint) { | 76 | public ViatraModelQueryBuilder query(Dnf query, QueryEvaluationHint queryEvaluationHint) { |
77 | query(query); | 77 | query(query); |
78 | hint(query, queryEvaluationHint); | 78 | hint(query, queryEvaluationHint); |
79 | return this; | 79 | return this; |
80 | } | 80 | } |
81 | 81 | ||
82 | @Override | 82 | @Override |
83 | public ViatraModelQueryBuilder computeHint(Function<DNF, QueryEvaluationHint> computeHint) { | 83 | public ViatraModelQueryBuilder computeHint(Function<Dnf, QueryEvaluationHint> computeHint) { |
84 | dnf2PQuery.setComputeHint(computeHint); | 84 | dnf2PQuery.setComputeHint(computeHint); |
85 | return this; | 85 | return this; |
86 | } | 86 | } |
87 | 87 | ||
88 | @Override | 88 | @Override |
89 | public ViatraModelQueryBuilder hint(DNF dnf, QueryEvaluationHint queryEvaluationHint) { | 89 | public ViatraModelQueryBuilder hint(Dnf dnf, QueryEvaluationHint queryEvaluationHint) { |
90 | var pQuery = dnf2PQuery.getAlreadyTranslated(dnf); | 90 | var pQuery = dnf2PQuery.getAlreadyTranslated(dnf); |
91 | if (pQuery == null) { | 91 | if (pQuery == null) { |
92 | throw new IllegalArgumentException( | 92 | throw new IllegalArgumentException( |
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 394e407e..8323118b 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 | |||
@@ -5,7 +5,7 @@ import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions; | |||
5 | import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; | 5 | import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; |
6 | import tools.refinery.store.model.Model; | 6 | import tools.refinery.store.model.Model; |
7 | import tools.refinery.store.model.ModelStore; | 7 | import tools.refinery.store.model.ModelStore; |
8 | import tools.refinery.store.query.DNF; | 8 | import tools.refinery.store.query.Dnf; |
9 | import tools.refinery.store.query.viatra.ViatraModelQueryStoreAdapter; | 9 | import tools.refinery.store.query.viatra.ViatraModelQueryStoreAdapter; |
10 | import tools.refinery.store.query.viatra.internal.pquery.RawPatternMatcher; | 10 | import tools.refinery.store.query.viatra.internal.pquery.RawPatternMatcher; |
11 | import tools.refinery.store.query.view.AnyRelationView; | 11 | import tools.refinery.store.query.view.AnyRelationView; |
@@ -17,11 +17,11 @@ public class ViatraModelQueryStoreAdapterImpl implements ViatraModelQueryStoreAd | |||
17 | private final ModelStore store; | 17 | private final ModelStore store; |
18 | private final ViatraQueryEngineOptions engineOptions; | 18 | private final ViatraQueryEngineOptions engineOptions; |
19 | private final Map<AnyRelationView, IInputKey> inputKeys; | 19 | private final Map<AnyRelationView, IInputKey> inputKeys; |
20 | private final Map<DNF, IQuerySpecification<RawPatternMatcher>> querySpecifications; | 20 | private final Map<Dnf, IQuerySpecification<RawPatternMatcher>> querySpecifications; |
21 | 21 | ||
22 | ViatraModelQueryStoreAdapterImpl(ModelStore store, ViatraQueryEngineOptions engineOptions, | 22 | ViatraModelQueryStoreAdapterImpl(ModelStore store, ViatraQueryEngineOptions engineOptions, |
23 | Map<AnyRelationView, IInputKey> inputKeys, | 23 | Map<AnyRelationView, IInputKey> inputKeys, |
24 | Map<DNF, IQuerySpecification<RawPatternMatcher>> querySpecifications) { | 24 | Map<Dnf, IQuerySpecification<RawPatternMatcher>> querySpecifications) { |
25 | this.store = store; | 25 | this.store = store; |
26 | this.engineOptions = engineOptions; | 26 | this.engineOptions = engineOptions; |
27 | this.inputKeys = inputKeys; | 27 | this.inputKeys = inputKeys; |
@@ -42,11 +42,11 @@ public class ViatraModelQueryStoreAdapterImpl implements ViatraModelQueryStoreAd | |||
42 | } | 42 | } |
43 | 43 | ||
44 | @Override | 44 | @Override |
45 | public Collection<DNF> getQueries() { | 45 | public Collection<Dnf> getQueries() { |
46 | return querySpecifications.keySet(); | 46 | return querySpecifications.keySet(); |
47 | } | 47 | } |
48 | 48 | ||
49 | Map<DNF, IQuerySpecification<RawPatternMatcher>> getQuerySpecifications() { | 49 | Map<Dnf, IQuerySpecification<RawPatternMatcher>> getQuerySpecifications() { |
50 | return querySpecifications; | 50 | return querySpecifications; |
51 | } | 51 | } |
52 | 52 | ||
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 60f1bcae..02e26bde 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 | |||
@@ -17,38 +17,38 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | |||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | 17 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; |
18 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | 18 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; |
19 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | 19 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; |
20 | import tools.refinery.store.query.DNF; | 20 | import tools.refinery.store.query.Dnf; |
21 | import tools.refinery.store.query.DNFAnd; | 21 | import tools.refinery.store.query.DnfClause; |
22 | import tools.refinery.store.query.DNFUtils; | 22 | import tools.refinery.store.query.DnfUtils; |
23 | import tools.refinery.store.query.Variable; | 23 | import tools.refinery.store.query.Variable; |
24 | import tools.refinery.store.query.atom.*; | 24 | import tools.refinery.store.query.literal.*; |
25 | import tools.refinery.store.query.view.AnyRelationView; | 25 | import tools.refinery.store.query.view.AnyRelationView; |
26 | 26 | ||
27 | import java.util.*; | 27 | import java.util.*; |
28 | import java.util.function.Function; | 28 | import java.util.function.Function; |
29 | import java.util.stream.Collectors; | 29 | import java.util.stream.Collectors; |
30 | 30 | ||
31 | public class DNF2PQuery { | 31 | public class Dnf2PQuery { |
32 | private static final Object P_CONSTRAINT_LOCK = new Object(); | 32 | private static final Object P_CONSTRAINT_LOCK = new Object(); |
33 | 33 | ||
34 | private final Set<DNF> translating = new LinkedHashSet<>(); | 34 | private final Set<Dnf> translating = new LinkedHashSet<>(); |
35 | 35 | ||
36 | private final Map<DNF, RawPQuery> dnf2PQueryMap = new HashMap<>(); | 36 | private final Map<Dnf, RawPQuery> dnf2PQueryMap = new HashMap<>(); |
37 | 37 | ||
38 | private final Map<AnyRelationView, RelationViewWrapper> view2WrapperMap = new LinkedHashMap<>(); | 38 | private final Map<AnyRelationView, RelationViewWrapper> view2WrapperMap = new LinkedHashMap<>(); |
39 | 39 | ||
40 | private final Map<AnyRelationView, RawPQuery> view2EmbeddedMap = new HashMap<>(); | 40 | private final Map<AnyRelationView, RawPQuery> view2EmbeddedMap = new HashMap<>(); |
41 | 41 | ||
42 | private Function<DNF, QueryEvaluationHint> computeHint = dnf -> new QueryEvaluationHint(null, | 42 | private Function<Dnf, QueryEvaluationHint> computeHint = dnf -> new QueryEvaluationHint(null, |
43 | QueryEvaluationHint.BackendRequirement.UNSPECIFIED); | 43 | QueryEvaluationHint.BackendRequirement.UNSPECIFIED); |
44 | 44 | ||
45 | public void setComputeHint(Function<DNF, QueryEvaluationHint> computeHint) { | 45 | public void setComputeHint(Function<Dnf, QueryEvaluationHint> computeHint) { |
46 | this.computeHint = computeHint; | 46 | this.computeHint = computeHint; |
47 | } | 47 | } |
48 | 48 | ||
49 | public RawPQuery translate(DNF dnfQuery) { | 49 | public RawPQuery translate(Dnf dnfQuery) { |
50 | if (translating.contains(dnfQuery)) { | 50 | if (translating.contains(dnfQuery)) { |
51 | var path = translating.stream().map(DNF::name).collect(Collectors.joining(" -> ")); | 51 | var path = translating.stream().map(Dnf::name).collect(Collectors.joining(" -> ")); |
52 | throw new IllegalStateException("Circular reference %s -> %s detected".formatted(path, | 52 | throw new IllegalStateException("Circular reference %s -> %s detected".formatted(path, |
53 | dnfQuery.name())); | 53 | dnfQuery.name())); |
54 | } | 54 | } |
@@ -71,11 +71,11 @@ public class DNF2PQuery { | |||
71 | return Collections.unmodifiableMap(view2WrapperMap); | 71 | return Collections.unmodifiableMap(view2WrapperMap); |
72 | } | 72 | } |
73 | 73 | ||
74 | public RawPQuery getAlreadyTranslated(DNF dnfQuery) { | 74 | public RawPQuery getAlreadyTranslated(Dnf dnfQuery) { |
75 | return dnf2PQueryMap.get(dnfQuery); | 75 | return dnf2PQueryMap.get(dnfQuery); |
76 | } | 76 | } |
77 | 77 | ||
78 | private RawPQuery doTranslate(DNF dnfQuery) { | 78 | private RawPQuery doTranslate(Dnf dnfQuery) { |
79 | var pQuery = new RawPQuery(dnfQuery.getUniqueName()); | 79 | var pQuery = new RawPQuery(dnfQuery.getUniqueName()); |
80 | pQuery.setEvaluationHints(computeHint.apply(dnfQuery)); | 80 | pQuery.setEvaluationHints(computeHint.apply(dnfQuery)); |
81 | 81 | ||
@@ -103,9 +103,9 @@ public class DNF2PQuery { | |||
103 | 103 | ||
104 | // The constructor of {@link org.eclipse.viatra.query.runtime.matchers.psystem.BasePConstraint} mutates | 104 | // The constructor of {@link org.eclipse.viatra.query.runtime.matchers.psystem.BasePConstraint} mutates |
105 | // global static state (<code>nextID</code>) without locking. Therefore, we need to synchronize before creating | 105 | // global static state (<code>nextID</code>) without locking. Therefore, we need to synchronize before creating |
106 | // any query constraints to avoid a data race. | 106 | // any query literals to avoid a data race. |
107 | synchronized (P_CONSTRAINT_LOCK) { | 107 | synchronized (P_CONSTRAINT_LOCK) { |
108 | for (DNFAnd clause : dnfQuery.getClauses()) { | 108 | for (DnfClause clause : dnfQuery.getClauses()) { |
109 | PBody body = new PBody(pQuery); | 109 | PBody body = new PBody(pQuery); |
110 | List<ExportedParameter> symbolicParameters = new ArrayList<>(); | 110 | List<ExportedParameter> symbolicParameters = new ArrayList<>(); |
111 | for (var param : dnfQuery.getParameters()) { | 111 | for (var param : dnfQuery.getParameters()) { |
@@ -114,8 +114,8 @@ public class DNF2PQuery { | |||
114 | } | 114 | } |
115 | body.setSymbolicParameters(symbolicParameters); | 115 | body.setSymbolicParameters(symbolicParameters); |
116 | pQuery.addBody(body); | 116 | pQuery.addBody(body); |
117 | for (DNFAtom constraint : clause.constraints()) { | 117 | for (Literal literal : clause.literals()) { |
118 | translateDNFAtom(constraint, body); | 118 | translateLiteral(literal, body); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
@@ -123,34 +123,34 @@ public class DNF2PQuery { | |||
123 | return pQuery; | 123 | return pQuery; |
124 | } | 124 | } |
125 | 125 | ||
126 | private void translateDNFAtom(DNFAtom constraint, PBody body) { | 126 | private void translateLiteral(Literal literal, PBody body) { |
127 | if (constraint instanceof EquivalenceAtom equivalenceAtom) { | 127 | if (literal instanceof EquivalenceLiteral equivalenceLiteral) { |
128 | translateEquivalenceAtom(equivalenceAtom, body); | 128 | translateEquivalenceLiteral(equivalenceLiteral, body); |
129 | } else if (constraint instanceof RelationViewAtom relationViewAtom) { | 129 | } else if (literal instanceof RelationViewLiteral relationViewLiteral) { |
130 | translateRelationViewAtom(relationViewAtom, body); | 130 | translateRelationViewLiteral(relationViewLiteral, body); |
131 | } else if (constraint instanceof DNFCallAtom callAtom) { | 131 | } else if (literal instanceof DnfCallLiteral dnfCallLiteral) { |
132 | translateCallAtom(callAtom, body); | 132 | translateDnfCallLiteral(dnfCallLiteral, body); |
133 | } else if (constraint instanceof ConstantAtom constantAtom) { | 133 | } else if (literal instanceof ConstantLiteral constantLiteral) { |
134 | translateConstantAtom(constantAtom, body); | 134 | translateConstantLiteral(constantLiteral, body); |
135 | } else { | 135 | } else { |
136 | throw new IllegalArgumentException("Unknown constraint: " + constraint.toString()); | 136 | throw new IllegalArgumentException("Unknown literal: " + literal.toString()); |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | private void translateEquivalenceAtom(EquivalenceAtom equivalence, PBody body) { | 140 | private void translateEquivalenceLiteral(EquivalenceLiteral equivalenceLiteral, PBody body) { |
141 | PVariable varSource = body.getOrCreateVariableByName(equivalence.left().getUniqueName()); | 141 | PVariable varSource = body.getOrCreateVariableByName(equivalenceLiteral.left().getUniqueName()); |
142 | PVariable varTarget = body.getOrCreateVariableByName(equivalence.right().getUniqueName()); | 142 | PVariable varTarget = body.getOrCreateVariableByName(equivalenceLiteral.right().getUniqueName()); |
143 | if (equivalence.positive()) { | 143 | if (equivalenceLiteral.positive()) { |
144 | new Equality(body, varSource, varTarget); | 144 | new Equality(body, varSource, varTarget); |
145 | } else { | 145 | } else { |
146 | new Inequality(body, varSource, varTarget); | 146 | new Inequality(body, varSource, varTarget); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | private void translateRelationViewAtom(RelationViewAtom relationViewAtom, PBody body) { | 150 | private void translateRelationViewLiteral(RelationViewLiteral relationViewLiteral, PBody body) { |
151 | var substitution = translateSubstitution(relationViewAtom.getSubstitution(), body); | 151 | var substitution = translateSubstitution(relationViewLiteral.getSubstitution(), body); |
152 | var polarity = relationViewAtom.getPolarity(); | 152 | var polarity = relationViewLiteral.getPolarity(); |
153 | var relationView = relationViewAtom.getTarget(); | 153 | var relationView = relationViewLiteral.getTarget(); |
154 | if (polarity == CallPolarity.POSITIVE) { | 154 | if (polarity == CallPolarity.POSITIVE) { |
155 | new TypeConstraint(body, substitution, wrapView(relationView)); | 155 | new TypeConstraint(body, substitution, wrapView(relationView)); |
156 | } else { | 156 | } else { |
@@ -178,7 +178,7 @@ public class DNF2PQuery { | |||
178 | } | 178 | } |
179 | 179 | ||
180 | private RawPQuery doTranslateEmbeddedRelationViewPQuery(AnyRelationView relationView) { | 180 | private RawPQuery doTranslateEmbeddedRelationViewPQuery(AnyRelationView relationView) { |
181 | var embeddedPQuery = new RawPQuery(DNFUtils.generateUniqueName(relationView.name()), PVisibility.EMBEDDED); | 181 | var embeddedPQuery = new RawPQuery(DnfUtils.generateUniqueName(relationView.name()), PVisibility.EMBEDDED); |
182 | var body = new PBody(embeddedPQuery); | 182 | var body = new PBody(embeddedPQuery); |
183 | int arity = relationView.arity(); | 183 | int arity = relationView.arity(); |
184 | var parameters = new ArrayList<PParameter>(arity); | 184 | var parameters = new ArrayList<PParameter>(arity); |
@@ -204,10 +204,10 @@ public class DNF2PQuery { | |||
204 | return view2WrapperMap.computeIfAbsent(relationView, RelationViewWrapper::new); | 204 | return view2WrapperMap.computeIfAbsent(relationView, RelationViewWrapper::new); |
205 | } | 205 | } |
206 | 206 | ||
207 | private void translateCallAtom(DNFCallAtom callAtom, PBody body) { | 207 | private void translateDnfCallLiteral(DnfCallLiteral dnfCallLiteral, PBody body) { |
208 | var variablesTuple = translateSubstitution(callAtom.getSubstitution(), body); | 208 | var variablesTuple = translateSubstitution(dnfCallLiteral.getSubstitution(), body); |
209 | var translatedReferred = translate(callAtom.getTarget()); | 209 | var translatedReferred = translate(dnfCallLiteral.getTarget()); |
210 | var polarity = callAtom.getPolarity(); | 210 | var polarity = dnfCallLiteral.getPolarity(); |
211 | switch (polarity) { | 211 | switch (polarity) { |
212 | case POSITIVE -> new PositivePatternCall(body, variablesTuple, translatedReferred); | 212 | case POSITIVE -> new PositivePatternCall(body, variablesTuple, translatedReferred); |
213 | case TRANSITIVE -> new BinaryTransitiveClosure(body, variablesTuple, translatedReferred); | 213 | case TRANSITIVE -> new BinaryTransitiveClosure(body, variablesTuple, translatedReferred); |
@@ -216,8 +216,8 @@ public class DNF2PQuery { | |||
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | private void translateConstantAtom(ConstantAtom constantAtom, PBody body) { | 219 | private void translateConstantLiteral(ConstantLiteral constantLiteral, PBody body) { |
220 | var variable = body.getOrCreateVariableByName(constantAtom.variable().getUniqueName()); | 220 | var variable = body.getOrCreateVariableByName(constantLiteral.variable().getUniqueName()); |
221 | new ConstantValue(body, variable, constantAtom.nodeId()); | 221 | new ConstantValue(body, variable, constantLiteral.nodeId()); |
222 | } | 222 | } |
223 | } | 223 | } |