diff options
author | 2021-08-11 04:12:24 +0200 | |
---|---|---|
committer | 2021-08-11 04:12:24 +0200 | |
commit | 3e59185e3d777751290618c6b283cc1d6086efdd (patch) | |
tree | d971a2f291962f5ae08fc65e1f23b79ad6262696 /model-data | |
parent | test environment to evaluate the return value of put (diff) | |
download | refinery-3e59185e3d777751290618c6b283cc1d6086efdd.tar.gz refinery-3e59185e3d777751290618c6b283cc1d6086efdd.tar.zst refinery-3e59185e3d777751290618c6b283cc1d6086efdd.zip |
renamed SymbolRepresentation to RelationRepresentation + added names
Diffstat (limited to 'model-data')
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/model/ModelStoreImpl.java | 12 | ||||
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/model/internal/SymbolRepresentationEquivalenceClass.java | 4 | ||||
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/AuxilaryDataRepresentation.java | 9 | ||||
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/DataRepresentation.java | 4 | ||||
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/RelationRepresentation.java (renamed from model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/SymbolRepresentation.java) | 11 |
5 files changed, 28 insertions, 12 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 5955f7a6..9225e50e 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 | |||
@@ -17,7 +17,7 @@ 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.AuxilaryDataRepresentation; |
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.SymbolRepresentation; | 20 | import org.eclipse.viatra.solver.data.model.representation.RelationRepresentation; |
21 | 21 | ||
22 | public class ModelStoreImpl implements ModelStore { | 22 | public class ModelStoreImpl implements ModelStore { |
23 | 23 | ||
@@ -31,11 +31,11 @@ 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<SymbolRepresentation<?>>> symbolRepresentationsPerHashPerArity = new HashMap<>(); | 34 | Map<SymbolRepresentationEquivalenceClass, List<RelationRepresentation<?>>> symbolRepresentationsPerHashPerArity = new HashMap<>(); |
35 | 35 | ||
36 | for (DataRepresentation<?, ?> dataRepresentation : dataRepresentations) { | 36 | for (DataRepresentation<?, ?> dataRepresentation : dataRepresentations) { |
37 | if (dataRepresentation instanceof SymbolRepresentation<?>) { | 37 | if (dataRepresentation instanceof RelationRepresentation<?>) { |
38 | SymbolRepresentation<?> symbolRepresentation = (SymbolRepresentation<?>) dataRepresentation; | 38 | RelationRepresentation<?> symbolRepresentation = (RelationRepresentation<?>) 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 AuxilaryDataRepresentation<?, ?>) { |
@@ -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<SymbolRepresentation<?>> symbolGroup : symbolRepresentationsPerHashPerArity.values()) { | 50 | for (List<RelationRepresentation<?>> 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<SymbolRepresentation<?>> symbolGroup) { | 58 | List<RelationRepresentation<?>> 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/internal/SymbolRepresentationEquivalenceClass.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/internal/SymbolRepresentationEquivalenceClass.java index b87b7c13..5a65deb2 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.SymbolRepresentation; | 7 | import org.eclipse.viatra.solver.data.model.representation.RelationRepresentation; |
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(SymbolRepresentation<?> representation) { | 14 | public SymbolRepresentationEquivalenceClass(RelationRepresentation<?> 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/AuxilaryDataRepresentation.java index 15116afd..b76acc23 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/AuxilaryDataRepresentation.java | |||
@@ -3,10 +3,17 @@ package org.eclipse.viatra.solver.data.model.representation; | |||
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 AuxilaryDataRepresentation<K,V> extends DataRepresentation<K, V> { |
6 | private final String name; | ||
6 | 7 | ||
7 | public AuxilaryDataRepresentation(Class<K> keyClass, ContinousHashProvider<K> hashProvider, Class<V> valueClass, | 8 | public AuxilaryDataRepresentation(String name, Class<K> keyClass, ContinousHashProvider<K> hashProvider, Class<V> valueClass, |
8 | V defaultValue) { | 9 | V defaultValue) { |
9 | super(keyClass, hashProvider, valueClass, defaultValue); | 10 | super(keyClass, hashProvider, valueClass, defaultValue); |
11 | this.name = name; | ||
12 | } | ||
13 | |||
14 | @Override | ||
15 | public String getName() { | ||
16 | return name; | ||
10 | } | 17 | } |
11 | 18 | ||
12 | @Override | 19 | @Override |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/DataRepresentation.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/DataRepresentation.java index e04606f5..28d8e2fb 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/DataRepresentation.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/DataRepresentation.java | |||
@@ -2,7 +2,7 @@ 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 | abstract public class DataRepresentation<K, V> { | 5 | public abstract class DataRepresentation<K, V> { |
6 | protected final Class<K> keyClass; | 6 | protected final Class<K> keyClass; |
7 | protected final Class<V> valueClass; | 7 | protected final Class<V> valueClass; |
8 | protected final ContinousHashProvider<K> hashProvider; | 8 | protected final ContinousHashProvider<K> hashProvider; |
@@ -16,6 +16,8 @@ abstract public class DataRepresentation<K, V> { | |||
16 | this.defaultValue = defaultValue; | 16 | this.defaultValue = defaultValue; |
17 | } | 17 | } |
18 | 18 | ||
19 | public abstract String getName(); | ||
20 | |||
19 | public Class<K> getKeyClass() { | 21 | public Class<K> getKeyClass() { |
20 | return keyClass; | 22 | return keyClass; |
21 | } | 23 | } |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/SymbolRepresentation.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/RelationRepresentation.java index c8b7473f..60e43692 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/SymbolRepresentation.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/model/representation/RelationRepresentation.java | |||
@@ -4,13 +4,18 @@ 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 SymbolRepresentation <D> extends DataRepresentation<Tuple,D> { | 7 | public class RelationRepresentation <D> extends DataRepresentation<Tuple,D> { |
8 | private final Symbol symbol; | 8 | private final Symbol symbol; |
9 | 9 | ||
10 | public SymbolRepresentation(Symbol symbol,Class<D> domain, D defaultValue) { | 10 | public RelationRepresentation(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 | } |
14 | |||
15 | @Override | ||
16 | public String getName() { | ||
17 | return symbol.getName(); | ||
18 | } | ||
14 | 19 | ||
15 | public Symbol getSymbol() { | 20 | public Symbol getSymbol() { |
16 | return symbol; | 21 | return symbol; |
@@ -20,4 +25,6 @@ public class SymbolRepresentation <D> extends DataRepresentation<Tuple,D> { | |||
20 | public boolean isValidKey(Tuple key) { | 25 | public boolean isValidKey(Tuple key) { |
21 | return key.getSize() == symbol.getArity(); | 26 | return key.getSize() == symbol.getArity(); |
22 | } | 27 | } |
28 | |||
29 | |||
23 | } | 30 | } |