diff options
Diffstat (limited to 'subprojects/store-query/src/main/java/tools/refinery/store/query/dnf')
3 files changed, 22 insertions, 6 deletions
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/ClausePostProcessor.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/ClausePostProcessor.java index 8800a155..7cd05364 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/ClausePostProcessor.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/ClausePostProcessor.java | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2021-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
@@ -112,7 +112,7 @@ class ClausePostProcessor { | |||
112 | .formatted(variable, representative)); | 112 | .formatted(variable, representative)); |
113 | } | 113 | } |
114 | return equivalencePartition.computeIfAbsent(variable, key -> { | 114 | return equivalencePartition.computeIfAbsent(variable, key -> { |
115 | var set = new HashSet<Variable>(1); | 115 | var set = HashSet.<Variable>newHashSet(1); |
116 | set.add(key); | 116 | set.add(key); |
117 | return set; | 117 | return set; |
118 | }); | 118 | }); |
@@ -193,7 +193,7 @@ class ClausePostProcessor { | |||
193 | } | 193 | } |
194 | 194 | ||
195 | private void topologicallySortLiterals() { | 195 | private void topologicallySortLiterals() { |
196 | topologicallySortedLiterals = new LinkedHashSet<>(substitutedLiterals.size()); | 196 | topologicallySortedLiterals = LinkedHashSet.newLinkedHashSet(substitutedLiterals.size()); |
197 | variableToLiteralInputMap = new HashMap<>(); | 197 | variableToLiteralInputMap = new HashMap<>(); |
198 | literalsWithAllInputsBound = new PriorityQueue<>(); | 198 | literalsWithAllInputsBound = new PriorityQueue<>(); |
199 | int size = substitutedLiterals.size(); | 199 | int size = substitutedLiterals.size(); |
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/DnfPostProcessor.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/DnfPostProcessor.java index 50236642..01344b59 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/DnfPostProcessor.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/DnfPostProcessor.java | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2023-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
@@ -26,7 +26,7 @@ class DnfPostProcessor { | |||
26 | 26 | ||
27 | public List<DnfClause> postProcessClauses() { | 27 | public List<DnfClause> postProcessClauses() { |
28 | var parameterInfoMap = getParameterInfoMap(); | 28 | var parameterInfoMap = getParameterInfoMap(); |
29 | var postProcessedClauses = new LinkedHashSet<CanonicalClause>(clauses.size()); | 29 | var postProcessedClauses = LinkedHashSet.<CanonicalClause>newLinkedHashSet(clauses.size()); |
30 | int index = 0; | 30 | int index = 0; |
31 | for (var literals : clauses) { | 31 | for (var literals : clauses) { |
32 | var postProcessor = new ClausePostProcessor(parameterInfoMap, literals); | 32 | var postProcessor = new ClausePostProcessor(parameterInfoMap, literals); |
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/FunctionalQuery.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/FunctionalQuery.java index 225f6844..b0a03c7d 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/FunctionalQuery.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/FunctionalQuery.java | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2021-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
@@ -94,6 +94,22 @@ public final class FunctionalQuery<T> extends Query<T> { | |||
94 | return aggregate(aggregator, List.of(arguments)); | 94 | return aggregate(aggregator, List.of(arguments)); |
95 | } | 95 | } |
96 | 96 | ||
97 | public AssignedValue<T> leftJoin(T defaultValue, List<NodeVariable> arguments) { | ||
98 | return targetVariable -> { | ||
99 | var placeholderVariable = Variable.of(type); | ||
100 | var argumentsWithPlaceholder = new ArrayList<Variable>(arguments.size() + 1); | ||
101 | argumentsWithPlaceholder.addAll(arguments); | ||
102 | argumentsWithPlaceholder.add(placeholderVariable); | ||
103 | return getDnf() | ||
104 | .leftJoinBy(placeholderVariable, defaultValue, argumentsWithPlaceholder) | ||
105 | .toLiteral(targetVariable); | ||
106 | }; | ||
107 | } | ||
108 | |||
109 | public AssignedValue<T> leftJoin(T defaultValue, NodeVariable... arguments) { | ||
110 | return leftJoin(defaultValue, List.of(arguments)); | ||
111 | } | ||
112 | |||
97 | @Override | 113 | @Override |
98 | public boolean equals(Object o) { | 114 | public boolean equals(Object o) { |
99 | if (this == o) return true; | 115 | if (this == o) return true; |