diff options
author | 2021-08-15 23:21:44 +0200 | |
---|---|---|
committer | 2021-08-15 23:21:44 +0200 | |
commit | f591f9813764eced466b8f17011a061f0010df64 (patch) | |
tree | a4ef1ed98398625678ba66300f044590aa1256b3 /model-data | |
parent | Initial commit of query integration, adapting the work of Attila Ficsor (diff) | |
download | refinery-f591f9813764eced466b8f17011a061f0010df64.tar.gz refinery-f591f9813764eced466b8f17011a061f0010df64.tar.zst refinery-f591f9813764eced466b8f17011a061f0010df64.zip |
Renamed RelationRepresentation to Relation
Diffstat (limited to 'model-data')
8 files changed, 29 insertions, 26 deletions
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelStoreImpl.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelStoreImpl.java index 9225e50e..1ff26a5c 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelStoreImpl.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelStoreImpl.java | |||
@@ -15,9 +15,9 @@ import org.eclipse.viatra.solver.data.map.VersionedMapStore; | |||
15 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | 15 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; |
16 | import org.eclipse.viatra.solver.data.model.internal.ModelImpl; | 16 | import org.eclipse.viatra.solver.data.model.internal.ModelImpl; |
17 | import org.eclipse.viatra.solver.data.model.internal.SymbolRepresentationEquivalenceClass; | 17 | import org.eclipse.viatra.solver.data.model.internal.SymbolRepresentationEquivalenceClass; |
18 | import org.eclipse.viatra.solver.data.model.representation.AuxilaryDataRepresentation; | 18 | import org.eclipse.viatra.solver.data.model.representation.AuxilaryData; |
19 | import org.eclipse.viatra.solver.data.model.representation.DataRepresentation; | 19 | import org.eclipse.viatra.solver.data.model.representation.DataRepresentation; |
20 | import org.eclipse.viatra.solver.data.model.representation.RelationRepresentation; | 20 | import org.eclipse.viatra.solver.data.model.representation.Relation; |
21 | 21 | ||
22 | public class ModelStoreImpl implements ModelStore { | 22 | public class ModelStoreImpl implements ModelStore { |
23 | 23 | ||
@@ -31,14 +31,14 @@ public class ModelStoreImpl implements ModelStore { | |||
31 | Set<DataRepresentation<?, ?>> dataRepresentations) { | 31 | Set<DataRepresentation<?, ?>> dataRepresentations) { |
32 | Map<DataRepresentation<?, ?>, VersionedMapStore<?, ?>> result = new HashMap<>(); | 32 | Map<DataRepresentation<?, ?>, VersionedMapStore<?, ?>> result = new HashMap<>(); |
33 | 33 | ||
34 | Map<SymbolRepresentationEquivalenceClass, List<RelationRepresentation<?>>> symbolRepresentationsPerHashPerArity = new HashMap<>(); | 34 | Map<SymbolRepresentationEquivalenceClass, List<Relation<?>>> symbolRepresentationsPerHashPerArity = new HashMap<>(); |
35 | 35 | ||
36 | for (DataRepresentation<?, ?> dataRepresentation : dataRepresentations) { | 36 | for (DataRepresentation<?, ?> dataRepresentation : dataRepresentations) { |
37 | if (dataRepresentation instanceof RelationRepresentation<?>) { | 37 | if (dataRepresentation instanceof Relation<?>) { |
38 | RelationRepresentation<?> symbolRepresentation = (RelationRepresentation<?>) dataRepresentation; | 38 | Relation<?> symbolRepresentation = (Relation<?>) dataRepresentation; |
39 | addOrCreate(symbolRepresentationsPerHashPerArity, | 39 | addOrCreate(symbolRepresentationsPerHashPerArity, |
40 | new SymbolRepresentationEquivalenceClass(symbolRepresentation), symbolRepresentation); | 40 | new SymbolRepresentationEquivalenceClass(symbolRepresentation), symbolRepresentation); |
41 | } else if (dataRepresentation instanceof AuxilaryDataRepresentation<?, ?>) { | 41 | } else if (dataRepresentation instanceof AuxilaryData<?, ?>) { |
42 | VersionedMapStoreImpl<?, ?> store = new VersionedMapStoreImpl<>(dataRepresentation.getHashProvider(), | 42 | VersionedMapStoreImpl<?, ?> store = new VersionedMapStoreImpl<>(dataRepresentation.getHashProvider(), |
43 | dataRepresentation.getDefaultValue()); | 43 | dataRepresentation.getDefaultValue()); |
44 | result.put(dataRepresentation, store); | 44 | result.put(dataRepresentation, store); |
@@ -47,7 +47,7 @@ public class ModelStoreImpl implements ModelStore { | |||
47 | "Model store does not have strategy to use " + dataRepresentation.getClass() + "!"); | 47 | "Model store does not have strategy to use " + dataRepresentation.getClass() + "!"); |
48 | } | 48 | } |
49 | } | 49 | } |
50 | for (List<RelationRepresentation<?>> symbolGroup : symbolRepresentationsPerHashPerArity.values()) { | 50 | for (List<Relation<?>> symbolGroup : symbolRepresentationsPerHashPerArity.values()) { |
51 | initRepresentationGroup(result, symbolGroup); | 51 | initRepresentationGroup(result, symbolGroup); |
52 | } | 52 | } |
53 | 53 | ||
@@ -55,7 +55,7 @@ public class ModelStoreImpl implements ModelStore { | |||
55 | } | 55 | } |
56 | 56 | ||
57 | private void initRepresentationGroup(Map<DataRepresentation<?, ?>, VersionedMapStore<?, ?>> result, | 57 | private void initRepresentationGroup(Map<DataRepresentation<?, ?>, VersionedMapStore<?, ?>> result, |
58 | List<RelationRepresentation<?>> symbolGroup) { | 58 | List<Relation<?>> symbolGroup) { |
59 | final ContinousHashProvider<Tuple> hashProvider = symbolGroup.get(0).getHashProvider(); | 59 | final ContinousHashProvider<Tuple> hashProvider = symbolGroup.get(0).getHashProvider(); |
60 | final Object defaultValue = symbolGroup.get(0).getDefaultValue(); | 60 | final Object defaultValue = symbolGroup.get(0).getDefaultValue(); |
61 | 61 | ||
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/Tuple.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/Tuple.java index eb99c862..4e7e7ba7 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/Tuple.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/Tuple.java | |||
@@ -3,7 +3,7 @@ package org.eclipse.viatra.solver.data.model; | |||
3 | import java.util.Arrays; | 3 | import java.util.Arrays; |
4 | 4 | ||
5 | public abstract class Tuple { | 5 | public abstract class Tuple { |
6 | private static final int CustomTupleSize = 2; | 6 | private static final int CUSTOMTUPLESIZE = 2; |
7 | 7 | ||
8 | public abstract int getSize(); | 8 | public abstract int getSize(); |
9 | public abstract int get(int element); | 9 | public abstract int get(int element); |
@@ -21,12 +21,15 @@ public abstract class Tuple { | |||
21 | b.append("]"); | 21 | b.append("]"); |
22 | return b.toString(); | 22 | return b.toString(); |
23 | } | 23 | } |
24 | public static Tuple1 of1(int value) { | ||
25 | return new Tuple1(value); | ||
26 | } | ||
24 | 27 | ||
25 | public static Tuple of(int... values) { | 28 | public static Tuple of(int... values) { |
26 | if(values.length == 0) { | 29 | if(values.length == 0) { |
27 | return new Tuple0(); | 30 | return new Tuple0(); |
28 | } else if(values.length == 1) { | 31 | } else if(values.length == 1) { |
29 | return new Tuple1(values[0]); | 32 | return of1(values[0]); |
30 | } else if(values.length == 2) { | 33 | } else if(values.length == 2) { |
31 | return new Tuple2(values[0],values[1]); | 34 | return new Tuple2(values[0],values[1]); |
32 | } else return new TupleN(values); | 35 | } else return new TupleN(values); |
@@ -104,7 +107,7 @@ public abstract class Tuple { | |||
104 | public static class TupleN extends Tuple{ | 107 | public static class TupleN extends Tuple{ |
105 | final int[] values; | 108 | final int[] values; |
106 | protected TupleN(int[] values) { | 109 | protected TupleN(int[] values) { |
107 | if(values.length<CustomTupleSize) | 110 | if(values.length<CUSTOMTUPLESIZE) |
108 | throw new IllegalArgumentException(); | 111 | throw new IllegalArgumentException(); |
109 | this.values = Arrays.copyOf(values, values.length); | 112 | this.values = Arrays.copyOf(values, values.length); |
110 | } | 113 | } |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/internal/SymbolRepresentationEquivalenceClass.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/internal/SymbolRepresentationEquivalenceClass.java index 5a65deb2..dff464c2 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/internal/SymbolRepresentationEquivalenceClass.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/internal/SymbolRepresentationEquivalenceClass.java | |||
@@ -4,14 +4,14 @@ import java.util.Objects; | |||
4 | 4 | ||
5 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | 5 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; |
6 | import org.eclipse.viatra.solver.data.model.Tuple; | 6 | import org.eclipse.viatra.solver.data.model.Tuple; |
7 | import org.eclipse.viatra.solver.data.model.representation.RelationRepresentation; | 7 | import org.eclipse.viatra.solver.data.model.representation.Relation; |
8 | 8 | ||
9 | public class SymbolRepresentationEquivalenceClass { | 9 | public class SymbolRepresentationEquivalenceClass { |
10 | final ContinousHashProvider<Tuple> hashProvider; | 10 | final ContinousHashProvider<Tuple> hashProvider; |
11 | final Class<?> domainClass; | 11 | final Class<?> domainClass; |
12 | final Object defaultValue; | 12 | final Object defaultValue; |
13 | final int arity; | 13 | final int arity; |
14 | public SymbolRepresentationEquivalenceClass(RelationRepresentation<?> representation) { | 14 | public SymbolRepresentationEquivalenceClass(Relation<?> representation) { |
15 | this.hashProvider = representation.getHashProvider(); | 15 | this.hashProvider = representation.getHashProvider(); |
16 | this.domainClass = representation.getValueClass(); | 16 | this.domainClass = representation.getValueClass(); |
17 | this.defaultValue = representation.getDefaultValue(); | 17 | this.defaultValue = representation.getDefaultValue(); |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/AuxilaryDataRepresentation.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/AuxilaryData.java index b76acc23..05715027 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/AuxilaryDataRepresentation.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/AuxilaryData.java | |||
@@ -2,10 +2,10 @@ package org.eclipse.viatra.solver.data.model.representation; | |||
2 | 2 | ||
3 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | 3 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; |
4 | 4 | ||
5 | public class AuxilaryDataRepresentation<K,V> extends DataRepresentation<K, V> { | 5 | public class AuxilaryData<K,V> extends DataRepresentation<K, V> { |
6 | private final String name; | 6 | private final String name; |
7 | 7 | ||
8 | public AuxilaryDataRepresentation(String name, Class<K> keyClass, ContinousHashProvider<K> hashProvider, Class<V> valueClass, | 8 | public AuxilaryData(String name, Class<K> keyClass, ContinousHashProvider<K> hashProvider, Class<V> valueClass, |
9 | V defaultValue) { | 9 | V defaultValue) { |
10 | super(keyClass, hashProvider, valueClass, defaultValue); | 10 | super(keyClass, hashProvider, valueClass, defaultValue); |
11 | this.name = name; | 11 | this.name = name; |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/RelationRepresentation.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/Relation.java index 6f01d8aa..28d00b2a 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/RelationRepresentation.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/Relation.java | |||
@@ -4,10 +4,10 @@ import org.eclipse.viatra.solver.data.model.Tuple; | |||
4 | import org.eclipse.viatra.solver.data.model.TupleHashProvider; | 4 | import org.eclipse.viatra.solver.data.model.TupleHashProvider; |
5 | import org.eclipse.viatra.solver.data.model.symbols.Symbol; | 5 | import org.eclipse.viatra.solver.data.model.symbols.Symbol; |
6 | 6 | ||
7 | public class RelationRepresentation<D> extends DataRepresentation<Tuple, D> { | 7 | public class Relation<D> extends DataRepresentation<Tuple, D> { |
8 | private final Symbol symbol; | 8 | private final Symbol symbol; |
9 | 9 | ||
10 | public RelationRepresentation(Symbol symbol, Class<D> domain, D defaultValue) { | 10 | public Relation(Symbol symbol, Class<D> domain, D defaultValue) { |
11 | super(Tuple.class, TupleHashProvider.singleton(), domain, defaultValue); | 11 | super(Tuple.class, TupleHashProvider.singleton(), domain, defaultValue); |
12 | this.symbol = symbol; | 12 | this.symbol = symbol; |
13 | } | 13 | } |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/FilteredRelationView.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/FilteredRelationView.java index b5660041..2f4661ae 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/FilteredRelationView.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/FilteredRelationView.java | |||
@@ -3,11 +3,11 @@ package org.eclipse.viatra.solver.data.query.relationView; | |||
3 | import org.eclipse.viatra.solver.data.model.Model; | 3 | import org.eclipse.viatra.solver.data.model.Model; |
4 | import org.eclipse.viatra.solver.data.model.Tuple; | 4 | import org.eclipse.viatra.solver.data.model.Tuple; |
5 | import org.eclipse.viatra.solver.data.model.Tuple.Tuple1; | 5 | import org.eclipse.viatra.solver.data.model.Tuple.Tuple1; |
6 | import org.eclipse.viatra.solver.data.model.representation.RelationRepresentation; | 6 | import org.eclipse.viatra.solver.data.model.representation.Relation; |
7 | 7 | ||
8 | public abstract class FilteredRelationView<D> extends RelationView<D>{ | 8 | public abstract class FilteredRelationView<D> extends RelationView<D>{ |
9 | 9 | ||
10 | protected FilteredRelationView(Model model, RelationRepresentation<D> representation) { | 10 | protected FilteredRelationView(Model model, Relation<D> representation) { |
11 | super(model, representation); | 11 | super(model, representation); |
12 | } | 12 | } |
13 | @Override | 13 | @Override |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/FunctionalRelationView.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/FunctionalRelationView.java index 2cd4b05e..69001606 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/FunctionalRelationView.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/FunctionalRelationView.java | |||
@@ -3,11 +3,11 @@ package org.eclipse.viatra.solver.data.query.relationView; | |||
3 | import org.eclipse.viatra.solver.data.model.Model; | 3 | import org.eclipse.viatra.solver.data.model.Model; |
4 | import org.eclipse.viatra.solver.data.model.Tuple; | 4 | import org.eclipse.viatra.solver.data.model.Tuple; |
5 | import org.eclipse.viatra.solver.data.model.Tuple.Tuple1; | 5 | import org.eclipse.viatra.solver.data.model.Tuple.Tuple1; |
6 | import org.eclipse.viatra.solver.data.model.representation.RelationRepresentation; | 6 | import org.eclipse.viatra.solver.data.model.representation.Relation; |
7 | 7 | ||
8 | public class FunctionalRelationView<D> extends RelationView<D> { | 8 | public class FunctionalRelationView<D> extends RelationView<D> { |
9 | 9 | ||
10 | protected FunctionalRelationView(Model model, RelationRepresentation<D> representation) { | 10 | protected FunctionalRelationView(Model model, Relation<D> representation) { |
11 | super(model, representation); | 11 | super(model, representation); |
12 | } | 12 | } |
13 | 13 | ||
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/RelationView.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/RelationView.java index 876f1dcc..08296705 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/RelationView.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/relationView/RelationView.java | |||
@@ -3,19 +3,19 @@ package org.eclipse.viatra.solver.data.query.relationView; | |||
3 | import org.eclipse.viatra.solver.data.map.CursorAsIterator; | 3 | import org.eclipse.viatra.solver.data.map.CursorAsIterator; |
4 | import org.eclipse.viatra.solver.data.model.Model; | 4 | import org.eclipse.viatra.solver.data.model.Model; |
5 | import org.eclipse.viatra.solver.data.model.Tuple; | 5 | import org.eclipse.viatra.solver.data.model.Tuple; |
6 | import org.eclipse.viatra.solver.data.model.representation.RelationRepresentation; | 6 | import org.eclipse.viatra.solver.data.model.representation.Relation; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Represents a view of a {@link RelationRepresentation} that can be queried. | 9 | * Represents a view of a {@link Relation} that can be queried. |
10 | * @author Oszkar Semerath | 10 | * @author Oszkar Semerath |
11 | * | 11 | * |
12 | * @param <D> | 12 | * @param <D> |
13 | */ | 13 | */ |
14 | public abstract class RelationView<D>{ | 14 | public abstract class RelationView<D>{ |
15 | protected final Model model; | 15 | protected final Model model; |
16 | protected final RelationRepresentation<D> representation; | 16 | protected final Relation<D> representation; |
17 | 17 | ||
18 | protected RelationView(Model model, RelationRepresentation<D> representation) { | 18 | protected RelationView(Model model, Relation<D> representation) { |
19 | this.model = model; | 19 | this.model = model; |
20 | this.representation = representation; | 20 | this.representation = representation; |
21 | } | 21 | } |
@@ -23,7 +23,7 @@ public abstract class RelationView<D>{ | |||
23 | public Model getModel() { | 23 | public Model getModel() { |
24 | return model; | 24 | return model; |
25 | } | 25 | } |
26 | public RelationRepresentation<D> getRepresentation() { | 26 | public Relation<D> getRepresentation() { |
27 | return representation; | 27 | return representation; |
28 | } | 28 | } |
29 | 29 | ||