diff options
author | Kristóf Marussy <kristof@marussy.com> | 2023-04-10 19:18:29 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2023-04-15 17:15:50 +0200 |
commit | 7c15c0e6e6a035458bdd89a939aacdf4a207e1cd (patch) | |
tree | e9318d8f1c326c05ee981e4ec966fb3fcffd6afa /subprojects/store-query/src/main/java/tools/refinery/store/query/view | |
parent | build: add workflow for REUSE compliance check (diff) | |
download | refinery-7c15c0e6e6a035458bdd89a939aacdf4a207e1cd.tar.gz refinery-7c15c0e6e6a035458bdd89a939aacdf4a207e1cd.tar.zst refinery-7c15c0e6e6a035458bdd89a939aacdf4a207e1cd.zip |
refactor: rename RelationView to SymbolView
* Add NodeFunctionView for symbols that hold function-like (single
associated object for each key) relations as integer values for performance.
Diffstat (limited to 'subprojects/store-query/src/main/java/tools/refinery/store/query/view')
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/view/AbstractFunctionView.java (renamed from subprojects/store-query/src/main/java/tools/refinery/store/query/view/FunctionalRelationView.java) | 44 | ||||
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/view/AnySymbolView.java (renamed from subprojects/store-query/src/main/java/tools/refinery/store/query/view/AnyRelationView.java) | 4 | ||||
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/view/FilteredView.java (renamed from subprojects/store-query/src/main/java/tools/refinery/store/query/view/FilteredRelationView.java) | 12 | ||||
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/view/ForbiddenView.java (renamed from subprojects/store-query/src/main/java/tools/refinery/store/query/view/ForbiddenRelationView.java) | 4 | ||||
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/view/KeyOnlyView.java (renamed from subprojects/store-query/src/main/java/tools/refinery/store/query/view/KeyOnlyRelationView.java) | 6 | ||||
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/view/MayView.java (renamed from subprojects/store-query/src/main/java/tools/refinery/store/query/view/MayRelationView.java) | 4 | ||||
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/view/MustView.java (renamed from subprojects/store-query/src/main/java/tools/refinery/store/query/view/MustRelationView.java) | 4 | ||||
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/view/RelationViewImplication.java | 24 | ||||
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/view/SymbolView.java (renamed from subprojects/store-query/src/main/java/tools/refinery/store/query/view/RelationView.java) | 8 | ||||
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/view/TuplePreservingView.java (renamed from subprojects/store-query/src/main/java/tools/refinery/store/query/view/TuplePreservingRelationView.java) | 11 |
10 files changed, 53 insertions, 68 deletions
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); |