aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar OszkarSemerath <semerath@mit.bme.hu>2021-08-01 23:15:14 +0200
committerLibravatar OszkarSemerath <semerath@mit.bme.hu>2021-08-01 23:15:14 +0200
commit5fcfaa77cb53a4516444bd43ce7c303c8f96020e (patch)
treee854882aa2eb0883aa649b7a525d1af70823d93d
parentModel representation is outdated. (diff)
downloadrefinery-5fcfaa77cb53a4516444bd43ce7c303c8f96020e.tar.gz
refinery-5fcfaa77cb53a4516444bd43ce7c303c8f96020e.tar.zst
refinery-5fcfaa77cb53a4516444bd43ce7c303c8f96020e.zip
Sonar fixes
-rw-r--r--model-data/src/main/java/org/eclipse/viatra/solver/data/map/ContinousHashProvider.java10
-rw-r--r--model-data/src/main/java/org/eclipse/viatra/solver/data/map/Versioned.java2
-rw-r--r--model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreConfiguration.java29
-rw-r--r--model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java29
-rw-r--r--model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java43
-rw-r--r--model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MapCursor.java10
-rw-r--r--model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MutableNode.java74
-rw-r--r--model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java28
-rw-r--r--model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/VersionedMapImpl.java13
-rw-r--r--model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/CommitSmokeTest.java2
-rw-r--r--model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/ContentEqualsSmokeTest.java3
-rw-r--r--model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/DiffCursorSmokeTest.java2
-rw-r--r--model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/MutableImmutableCompareSmokeTest.java2
-rw-r--r--model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/MutableSmokeTest.java2
-rw-r--r--model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/RestoreSmokeTest.java2
-rw-r--r--model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/SmokeTestUtils.java3
16 files changed, 128 insertions, 126 deletions
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/ContinousHashProvider.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/ContinousHashProvider.java
index 3f019b24..dd64f901 100644
--- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/ContinousHashProvider.java
+++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/ContinousHashProvider.java
@@ -11,7 +11,7 @@ import org.eclipse.viatra.solver.data.map.internal.Node;
11 * @param <K> Target java type. 11 * @param <K> Target java type.
12 */ 12 */
13public interface ContinousHashProvider<K> { 13public interface ContinousHashProvider<K> {
14 public static final int EFFECTIVE_BITS = Node.effectiveBits; 14 public static final int EFFECTIVE_BITS = Node.EFFECTIVE_BITS;
15 public static final int EFFECTIVE_BIT_MASK = (1 << (EFFECTIVE_BITS)) - 1; 15 public static final int EFFECTIVE_BIT_MASK = (1 << (EFFECTIVE_BITS)) - 1;
16 16
17 /** 17 /**
@@ -51,10 +51,10 @@ public interface ContinousHashProvider<K> {
51 for (int i = 0; i < ContinousHashProvider.MAX_PRACTICAL_DEPTH; i++) { 51 for (int i = 0; i < ContinousHashProvider.MAX_PRACTICAL_DEPTH; i++) {
52 int hash1 = getEffectiveHash(key1, i); 52 int hash1 = getEffectiveHash(key1, i);
53 int hash2 = getEffectiveHash(key2, i); 53 int hash2 = getEffectiveHash(key2, i);
54 for(int j = 0; j<Integer.SIZE/Node.branchingFactorBit; j++) { 54 for(int j = 0; j<Integer.SIZE/Node.BRANCHING_FACTOR_BITS; j++) {
55 final int factorMask = (1<<Node.branchingFactorBit)-1; 55 final int factorMask = (1<<Node.BRANCHING_FACTOR_BITS)-1;
56 int hashFragment1 = (hash1>>>j*Node.branchingFactorBit) & factorMask; 56 int hashFragment1 = (hash1>>>j*Node.BRANCHING_FACTOR_BITS) & factorMask;
57 int hashFragment2 = (hash2>>>j*Node.branchingFactorBit) & factorMask; 57 int hashFragment2 = (hash2>>>j*Node.BRANCHING_FACTOR_BITS) & factorMask;
58 var result = Integer.compare(hashFragment1, hashFragment2); 58 var result = Integer.compare(hashFragment1, hashFragment2);
59 if (result != 0) { 59 if (result != 0) {
60 return result; 60 return result;
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/Versioned.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/Versioned.java
index 68970a94..e46be237 100644
--- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/Versioned.java
+++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/Versioned.java
@@ -2,6 +2,6 @@ package org.eclipse.viatra.solver.data.map;
2 2
3public interface Versioned { 3public interface Versioned {
4 public long commit(); 4 public long commit();
5 //public void revert(); 5 //maybe revert()?
6 public void restore(long state); 6 public void restore(long state);
7} 7}
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreConfiguration.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreConfiguration.java
index 196adf2c..be768e98 100644
--- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreConfiguration.java
+++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreConfiguration.java
@@ -1,12 +1,27 @@
1package org.eclipse.viatra.solver.data.map; 1package org.eclipse.viatra.solver.data.map;
2 2
3public class VersionedMapStoreConfiguration { 3public class VersionedMapStoreConfiguration {
4
5 public VersionedMapStoreConfiguration() {
6
7 }
8 public VersionedMapStoreConfiguration(boolean immutableWhenCommiting, boolean sharedNodeCacheInStore,
9 boolean sharedNodeCacheInStoreGroups) {
10 super();
11 this.immutableWhenCommiting = immutableWhenCommiting;
12 this.sharedNodeCacheInStore = sharedNodeCacheInStore;
13 this.sharedNodeCacheInStoreGroups = sharedNodeCacheInStoreGroups;
14 }
15
4 /** 16 /**
5 * If true root is replaced with immutable node when committed. Frees up memory 17 * If true root is replaced with immutable node when committed. Frees up memory
6 * by releasing immutable nodes, but it may decrease performance by recreating 18 * by releasing immutable nodes, but it may decrease performance by recreating
7 * immutable nodes upon changes (some evidence). 19 * immutable nodes upon changes (some evidence).
8 */ 20 */
9 public boolean immutableWhenCommiting = true; 21 private boolean immutableWhenCommiting = true;
22 public boolean isImmutableWhenCommiting() {
23 return immutableWhenCommiting;
24 }
10 25
11 /** 26 /**
12 * If true, all subnodes are cached within a {@link VersionedMapStore}. It 27 * If true, all subnodes are cached within a {@link VersionedMapStore}. It
@@ -15,13 +30,19 @@ public class VersionedMapStoreConfiguration {
15 * decrease performance (no example found). The option permits the efficient 30 * decrease performance (no example found). The option permits the efficient
16 * implementation of version deletion. 31 * implementation of version deletion.
17 */ 32 */
18 public boolean sharedNodeCacheInStore = true; 33 private boolean sharedNodeCacheInStore = true;
19 34 public boolean isSharedNodeCacheInStore() {
35 return sharedNodeCacheInStore;
36 }
37
20 /** 38 /**
21 * If true, all subnodes are cached within a group of 39 * If true, all subnodes are cached within a group of
22 * {@link VersionedMapStoreImpl#createSharedVersionedMapStores(int, ContinousHashProvider, Object, VersionedMapStoreConfiguration)}. 40 * {@link VersionedMapStoreImpl#createSharedVersionedMapStores(int, ContinousHashProvider, Object, VersionedMapStoreConfiguration)}.
23 * If {@link VersionedMapStoreConfiguration#sharedNodeCacheInStore} is 41 * If {@link VersionedMapStoreConfiguration#sharedNodeCacheInStore} is
24 * <code>false</code>, then it has currently no impact. 42 * <code>false</code>, then it has currently no impact.
25 */ 43 */
26 public boolean sharedNodeCacheInStoreGroups = true; 44 private boolean sharedNodeCacheInStoreGroups = true;
45 public boolean isSharedNodeCacheInStoreGroups() {
46 return sharedNodeCacheInStoreGroups;
47 }
27} 48}
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java
index 5bcbf0c4..ab55e4bc 100644
--- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java
+++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java
@@ -1,6 +1,7 @@
1package org.eclipse.viatra.solver.data.map; 1package org.eclipse.viatra.solver.data.map;
2 2
3import java.util.ArrayList; 3import java.util.ArrayList;
4import java.util.Arrays;
4import java.util.Collections; 5import java.util.Collections;
5import java.util.HashMap; 6import java.util.HashMap;
6import java.util.List; 7import java.util.List;
@@ -17,7 +18,7 @@ public class VersionedMapStoreImpl<K, V> implements VersionedMapStore<K, V> {
17 private final boolean immutableWhenCommiting; 18 private final boolean immutableWhenCommiting;
18 19
19 // Static data 20 // Static data
20 protected final ContinousHashProvider<? super K> hashProvider; 21 protected final ContinousHashProvider<K> hashProvider;
21 protected final V defaultValue; 22 protected final V defaultValue;
22 23
23 // Dynamic data 24 // Dynamic data
@@ -25,12 +26,12 @@ public class VersionedMapStoreImpl<K, V> implements VersionedMapStore<K, V> {
25 protected final Map<Node<K, V>, ImmutableNode<K, V>> nodeCache; 26 protected final Map<Node<K, V>, ImmutableNode<K, V>> nodeCache;
26 protected long nextID = 0; 27 protected long nextID = 0;
27 28
28 public VersionedMapStoreImpl(ContinousHashProvider<? super K> hashProvider, V defaultValue, 29 public VersionedMapStoreImpl(ContinousHashProvider<K> hashProvider, V defaultValue,
29 VersionedMapStoreConfiguration config) { 30 VersionedMapStoreConfiguration config) {
30 this.immutableWhenCommiting = config.immutableWhenCommiting; 31 this.immutableWhenCommiting = config.isImmutableWhenCommiting();
31 this.hashProvider = hashProvider; 32 this.hashProvider = hashProvider;
32 this.defaultValue = defaultValue; 33 this.defaultValue = defaultValue;
33 if (config.sharedNodeCacheInStore) { 34 if (config.isSharedNodeCacheInStore()) {
34 nodeCache = new HashMap<>(); 35 nodeCache = new HashMap<>();
35 } else { 36 } else {
36 nodeCache = null; 37 nodeCache = null;
@@ -39,7 +40,7 @@ public class VersionedMapStoreImpl<K, V> implements VersionedMapStore<K, V> {
39 40
40 private VersionedMapStoreImpl(ContinousHashProvider<K> hashProvider, V defaultValue, 41 private VersionedMapStoreImpl(ContinousHashProvider<K> hashProvider, V defaultValue,
41 Map<Node<K, V>, ImmutableNode<K, V>> nodeCache, VersionedMapStoreConfiguration config) { 42 Map<Node<K, V>, ImmutableNode<K, V>> nodeCache, VersionedMapStoreConfiguration config) {
42 this.immutableWhenCommiting = config.immutableWhenCommiting; 43 this.immutableWhenCommiting = config.isImmutableWhenCommiting();
43 this.hashProvider = hashProvider; 44 this.hashProvider = hashProvider;
44 this.defaultValue = defaultValue; 45 this.defaultValue = defaultValue;
45 this.nodeCache = nodeCache; 46 this.nodeCache = nodeCache;
@@ -53,19 +54,19 @@ public class VersionedMapStoreImpl<K, V> implements VersionedMapStore<K, V> {
53 ContinousHashProvider<K> hashProvider, V defaultValue, 54 ContinousHashProvider<K> hashProvider, V defaultValue,
54 VersionedMapStoreConfiguration config) { 55 VersionedMapStoreConfiguration config) {
55 List<VersionedMapStore<K, V>> result = new ArrayList<>(amount); 56 List<VersionedMapStore<K, V>> result = new ArrayList<>(amount);
56 if (config.sharedNodeCacheInStoreGroups) { 57 if (config.isSharedNodeCacheInStoreGroups()) {
57 Map<Node<K, V>, ImmutableNode<K, V>> nodeCache; 58 Map<Node<K, V>, ImmutableNode<K, V>> nodeCache;
58 if (config.sharedNodeCacheInStore) { 59 if (config.isSharedNodeCacheInStore()) {
59 nodeCache = new HashMap<>(); 60 nodeCache = new HashMap<>();
60 } else { 61 } else {
61 nodeCache = null; 62 nodeCache = null;
62 } 63 }
63 for (int i = 0; i < amount; i++) { 64 for (int i = 0; i < amount; i++) {
64 result.add(new VersionedMapStoreImpl<K, V>(hashProvider, defaultValue, nodeCache, config)); 65 result.add(new VersionedMapStoreImpl<>(hashProvider, defaultValue, nodeCache, config));
65 } 66 }
66 } else { 67 } else {
67 for (int i = 0; i < amount; i++) { 68 for (int i = 0; i < amount; i++) {
68 result.add(new VersionedMapStoreImpl<K, V>(hashProvider, defaultValue, config)); 69 result.add(new VersionedMapStoreImpl<>(hashProvider, defaultValue, config));
69 } 70 }
70 } 71 }
71 return result; 72 return result;
@@ -82,23 +83,23 @@ public class VersionedMapStoreImpl<K, V> implements VersionedMapStore<K, V> {
82 83
83 @Override 84 @Override
84 public VersionedMap<K, V> createMap() { 85 public VersionedMap<K, V> createMap() {
85 return new VersionedMapImpl<K, V>(this, hashProvider, defaultValue); 86 return new VersionedMapImpl<>(this, hashProvider, defaultValue);
86 } 87 }
87 88
88 @Override 89 @Override
89 public VersionedMap<K, V> createMap(long state) { 90 public VersionedMap<K, V> createMap(long state) {
90 ImmutableNode<K, V> data = revert(state); 91 ImmutableNode<K, V> data = revert(state);
91 return new VersionedMapImpl<K, V>(this, hashProvider, defaultValue, data); 92 return new VersionedMapImpl<>(this, hashProvider, defaultValue, data);
92 } 93 }
93 94
94 public synchronized ImmutableNode<K, V> revert(long state) { 95 public synchronized ImmutableNode<K, V> revert(long state) {
95 if (states.containsKey(state)) { 96 if (states.containsKey(state)) {
96 return states.get(state); 97 return states.get(state);
97 } else { 98 } else {
98 ArrayList<Long> existingKeys = new ArrayList<Long>(states.keySet()); 99 ArrayList<Long> existingKeys = new ArrayList<>(states.keySet());
99 Collections.sort(existingKeys); 100 Collections.sort(existingKeys);
100 throw new IllegalArgumentException("Store does not contain state " + state + "! Avaliable states: " 101 throw new IllegalArgumentException("Store does not contain state " + state + "! Avaliable states: "
101 + existingKeys.toArray().toString()); 102 + Arrays.toString(existingKeys.toArray()));
102 } 103 }
103 } 104 }
104 105
@@ -126,6 +127,6 @@ public class VersionedMapStoreImpl<K, V> implements VersionedMapStore<K, V> {
126 VersionedMap<K, V> map2 = createMap(toState); 127 VersionedMap<K, V> map2 = createMap(toState);
127 Cursor<K, V> cursor1 = map1.getCursor(); 128 Cursor<K, V> cursor1 = map1.getCursor();
128 Cursor<K, V> cursor2 = map2.getCursor(); 129 Cursor<K, V> cursor2 = map2.getCursor();
129 return new MapDiffCursor<K, V>(this.hashProvider, this.defaultValue, cursor1, cursor2); 130 return new MapDiffCursor<>(this.hashProvider, this.defaultValue, cursor1, cursor2);
130 } 131 }
131} 132}
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java
index a469326e..99df4d48 100644
--- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java
+++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java
@@ -66,7 +66,7 @@ public class ImmutableNode<K, V> extends Node<K, V> {
66 int resultNodeMap = 0; 66 int resultNodeMap = 0;
67 final Object[] resultContent = new Object[size]; 67 final Object[] resultContent = new Object[size];
68 int bitposition = 1; 68 int bitposition = 1;
69 for(int i = 0; i<factor; i++) { 69 for(int i = 0; i<FACTOR; i++) {
70 Object key = node.content[i*2]; 70 Object key = node.content[i*2];
71 if(key != null) { 71 if(key != null) {
72 resultDataMap |= bitposition; 72 resultDataMap |= bitposition;
@@ -139,16 +139,14 @@ public class ImmutableNode<K, V> extends Node<K, V> {
139 if(value == defaultValue) { 139 if(value == defaultValue) {
140 // delete 140 // delete
141 MutableNode<K, V> mutable = this.toMutable(); 141 MutableNode<K, V> mutable = this.toMutable();
142 Node<K, V> result = mutable.removeEntry(selectedHashFragment); 142 return mutable.removeEntry(selectedHashFragment);
143 return result;
144 } else if(value == content[keyIndex+1]) { 143 } else if(value == content[keyIndex+1]) {
145 // dont change 144 // dont change
146 return this; 145 return this;
147 } else { 146 } else {
148 // update existing value 147 // update existing value
149 MutableNode<K, V> mutable = this.toMutable(); 148 MutableNode<K, V> mutable = this.toMutable();
150 Node<K, V> result = mutable.updateValue(value, selectedHashFragment); 149 return mutable.updateValue(value, selectedHashFragment);
151 return result;
152 } 150 }
153 } else { 151 } else {
154 if(value == defaultValue) { 152 if(value == defaultValue) {
@@ -157,8 +155,7 @@ public class ImmutableNode<K, V> extends Node<K, V> {
157 } else { 155 } else {
158 // add new key + value 156 // add new key + value
159 MutableNode<K, V> mutable = this.toMutable(); 157 MutableNode<K, V> mutable = this.toMutable();
160 Node<K, V> result = mutable.putValue(key, value, hashProvider, defaultValue, hash, depth); 158 return mutable.putValue(key, value, hashProvider, defaultValue, hash, depth);
161 return result;
162 } 159 }
163 } 160 }
164 } else if((nodeMap & bitposition)!=0) { 161 } else if((nodeMap & bitposition)!=0) {
@@ -174,14 +171,12 @@ public class ImmutableNode<K, V> extends Node<K, V> {
174 return this; 171 return this;
175 } else { 172 } else {
176 MutableNode<K, V> mutable = toMutable(); 173 MutableNode<K, V> mutable = toMutable();
177 Node<K, V> result = mutable.updateWithSubNode(selectedHashFragment, newsubNode, value.equals(defaultValue)); 174 return mutable.updateWithSubNode(selectedHashFragment, newsubNode, value.equals(defaultValue));
178 return result;
179 } 175 }
180 } else { 176 } else {
181 // add new key + value 177 // add new key + value
182 MutableNode<K, V> mutable = this.toMutable(); 178 MutableNode<K, V> mutable = this.toMutable();
183 Node<K, V> result = mutable.putValue(key, value, hashProvider, defaultValue, hash, depth); 179 return mutable.putValue(key, value, hashProvider, defaultValue, hash, depth);
184 return result;
185 } 180 }
186 } 181 }
187 182
@@ -200,7 +195,7 @@ public class ImmutableNode<K, V> extends Node<K, V> {
200 195
201 @Override 196 @Override
202 protected MutableNode<K,V> toMutable() { 197 protected MutableNode<K,V> toMutable() {
203 return new MutableNode<K,V>(this); 198 return new MutableNode<>(this);
204 } 199 }
205 200
206 @Override 201 @Override
@@ -219,7 +214,7 @@ public class ImmutableNode<K, V> extends Node<K, V> {
219 boolean moveToNext(MapCursor<K, V> cursor) { 214 boolean moveToNext(MapCursor<K, V> cursor) {
220 // 1. try to move to data 215 // 1. try to move to data
221 int datas = Integer.bitCount(this.dataMap); 216 int datas = Integer.bitCount(this.dataMap);
222 if(cursor.dataIndex != MapCursor.IndexFinish) { 217 if(cursor.dataIndex != MapCursor.INDEX_FINISH) {
223 int newDataIndex = cursor.dataIndex + 1; 218 int newDataIndex = cursor.dataIndex + 1;
224 if(newDataIndex < datas) { 219 if(newDataIndex < datas) {
225 cursor.dataIndex = newDataIndex; 220 cursor.dataIndex = newDataIndex;
@@ -227,7 +222,7 @@ public class ImmutableNode<K, V> extends Node<K, V> {
227 cursor.value = (V) this.content[newDataIndex*2+1]; 222 cursor.value = (V) this.content[newDataIndex*2+1];
228 return true; 223 return true;
229 } else { 224 } else {
230 cursor.dataIndex = MapCursor.IndexFinish; 225 cursor.dataIndex = MapCursor.INDEX_FINISH;
231 } 226 }
232 } 227 }
233 228
@@ -237,10 +232,10 @@ public class ImmutableNode<K, V> extends Node<K, V> {
237 if(newNodeIndex < nodes) { 232 if(newNodeIndex < nodes) {
238 // 2.1 found next subnode, move down to the subnode 233 // 2.1 found next subnode, move down to the subnode
239 Node<K, V> subnode = (Node<K, V>) this.content[this.content.length-1-newNodeIndex]; 234 Node<K, V> subnode = (Node<K, V>) this.content[this.content.length-1-newNodeIndex];
240 cursor.dataIndex = MapCursor.IndexStart; 235 cursor.dataIndex = MapCursor.INDEX_START;
241 cursor.nodeIndexStack.pop(); 236 cursor.nodeIndexStack.pop();
242 cursor.nodeIndexStack.push(newNodeIndex); 237 cursor.nodeIndexStack.push(newNodeIndex);
243 cursor.nodeIndexStack.push(MapCursor.IndexStart); 238 cursor.nodeIndexStack.push(MapCursor.INDEX_START);
244 cursor.nodeStack.push(subnode); 239 cursor.nodeStack.push(subnode);
245 return subnode.moveToNext(cursor); 240 return subnode.moveToNext(cursor);
246 } else { 241 } else {
@@ -270,7 +265,7 @@ public class ImmutableNode<K, V> extends Node<K, V> {
270 builder.append("Immutable("); 265 builder.append("Immutable(");
271 boolean hadContent = false; 266 boolean hadContent = false;
272 int dataMask = 1; 267 int dataMask = 1;
273 for(int i = 0; i<factor; i++) { 268 for(int i = 0; i<FACTOR; i++) {
274 if((dataMask & dataMap) != 0) { 269 if((dataMask & dataMap) != 0) {
275 if(hadContent) { 270 if(hadContent) {
276 builder.append(","); 271 builder.append(",");
@@ -287,7 +282,7 @@ public class ImmutableNode<K, V> extends Node<K, V> {
287 } 282 }
288 builder.append(")"); 283 builder.append(")");
289 int nodeMask = 1; 284 int nodeMask = 1;
290 for(int i = 0; i<factor; i++) { 285 for(int i = 0; i<FACTOR; i++) {
291 if((nodeMask & nodeMap)!=0) { 286 if((nodeMask & nodeMap)!=0) {
292 @SuppressWarnings("unchecked") 287 @SuppressWarnings("unchecked")
293 Node<K,V> subNode = (Node<K, V>) content[content.length-1-index(nodeMap, nodeMask)]; 288 Node<K,V> subNode = (Node<K, V>) content[content.length-1-index(nodeMap, nodeMask)];
@@ -333,15 +328,9 @@ public class ImmutableNode<K, V> extends Node<K, V> {
333 return false; 328 return false;
334 if (obj instanceof ImmutableNode<?,?>) { 329 if (obj instanceof ImmutableNode<?,?>) {
335 ImmutableNode<?,?> other = (ImmutableNode<?,?>) obj; 330 ImmutableNode<?,?> other = (ImmutableNode<?,?>) obj;
336 if (precalculatedHash != other.precalculatedHash) 331 if (precalculatedHash != other.precalculatedHash || dataMap != other.dataMap || nodeMap != other.nodeMap || !Arrays.deepEquals(content, other.content))
337 return false; 332 return false;
338 if (dataMap != other.dataMap) 333 else return true;
339 return false;
340 if (nodeMap != other.nodeMap)
341 return false;
342 if (!Arrays.deepEquals(content, other.content))
343 return false;
344 return true;
345 } else if(obj instanceof MutableNode<?,?>) { 334 } else if(obj instanceof MutableNode<?,?>) {
346 return ImmutableNode.compareImmutableMutable(this, (MutableNode<?, ?>) obj); 335 return ImmutableNode.compareImmutableMutable(this, (MutableNode<?, ?>) obj);
347 } else { 336 } else {
@@ -355,7 +344,7 @@ public class ImmutableNode<K, V> extends Node<K, V> {
355 int datas = 0; 344 int datas = 0;
356 int nodes = 0; 345 int nodes = 0;
357 final int immutableLength = immutable.content.length; 346 final int immutableLength = immutable.content.length;
358 for(int i = 0; i<factor; i++) { 347 for(int i = 0; i<FACTOR; i++) {
359 Object key = mutable.content[i*2]; 348 Object key = mutable.content[i*2];
360 // For each key candidate 349 // For each key candidate
361 if(key != null) { 350 if(key != null) {
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MapCursor.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MapCursor.java
index a18d540d..97fbcd8f 100644
--- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MapCursor.java
+++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MapCursor.java
@@ -10,8 +10,8 @@ import org.eclipse.viatra.solver.data.map.VersionedMap;
10 10
11public class MapCursor<K,V> implements Cursor<K,V> { 11public class MapCursor<K,V> implements Cursor<K,V> {
12 // Constants 12 // Constants
13 static int IndexStart = -1; 13 static final int INDEX_START = -1;
14 static int IndexFinish = -2; 14 static final int INDEX_FINISH = -2;
15 15
16 // Tree stack 16 // Tree stack
17 ArrayDeque<Node<K,V>> nodeStack; 17 ArrayDeque<Node<K,V>> nodeStack;
@@ -33,10 +33,10 @@ public class MapCursor<K,V> implements Cursor<K,V> {
33 this.nodeIndexStack = new ArrayDeque<>(); 33 this.nodeIndexStack = new ArrayDeque<>();
34 if(root != null) { 34 if(root != null) {
35 this.nodeStack.add(root); 35 this.nodeStack.add(root);
36 this.nodeIndexStack.push(IndexStart); 36 this.nodeIndexStack.push(INDEX_START);
37 } 37 }
38 38
39 this.dataIndex = IndexStart; 39 this.dataIndex = INDEX_START;
40 40
41 // Initializing cache 41 // Initializing cache
42 this.key = null; 42 this.key = null;
@@ -75,7 +75,7 @@ public class MapCursor<K,V> implements Cursor<K,V> {
75 public boolean skipCurrentNode() { 75 public boolean skipCurrentNode() {
76 nodeStack.pop(); 76 nodeStack.pop();
77 nodeIndexStack.pop(); 77 nodeIndexStack.pop();
78 dataIndex = IndexFinish; 78 dataIndex = INDEX_FINISH;
79 return move(); 79 return move();
80 } 80 }
81 @Override 81 @Override
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MutableNode.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MutableNode.java
index 322e2128..2f794a7b 100644
--- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MutableNode.java
+++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MutableNode.java
@@ -10,18 +10,18 @@ public class MutableNode<K, V> extends Node<K, V> {
10 protected Object[] content; 10 protected Object[] content;
11 11
12 protected MutableNode() { 12 protected MutableNode() {
13 this.content = new Object[2 * factor]; 13 this.content = new Object[2 * FACTOR];
14 updateHash(); 14 updateHash();
15 } 15 }
16 16
17 public static <K, V> MutableNode<K, V> initialize(K key, V value, 17 public static <K, V> MutableNode<K, V> initialize(K key, V value, ContinousHashProvider<? super K> hashProvider,
18 ContinousHashProvider<? super K> hashProvider, V defaultValue) { 18 V defaultValue) {
19 if (value == defaultValue) { 19 if (value == defaultValue) {
20 return null; 20 return null;
21 } else { 21 } else {
22 int hash = hashProvider.getHash(key, 0); 22 int hash = hashProvider.getHash(key, 0);
23 int fragment = hashFragment(hash, 0); 23 int fragment = hashFragment(hash, 0);
24 MutableNode<K, V> res = new MutableNode<K, V>(); 24 MutableNode<K, V> res = new MutableNode<>();
25 res.content[2 * fragment] = key; 25 res.content[2 * fragment] = key;
26 res.content[2 * fragment + 1] = value; 26 res.content[2 * fragment + 1] = value;
27 res.updateHash(); 27 res.updateHash();
@@ -35,10 +35,10 @@ public class MutableNode<K, V> extends Node<K, V> {
35 * @param node 35 * @param node
36 */ 36 */
37 protected MutableNode(ImmutableNode<K, V> node) { 37 protected MutableNode(ImmutableNode<K, V> node) {
38 this.content = new Object[2 * factor]; 38 this.content = new Object[2 * FACTOR];
39 int dataUsed = 0; 39 int dataUsed = 0;
40 int nodeUsed = 0; 40 int nodeUsed = 0;
41 for (int i = 0; i < factor; i++) { 41 for (int i = 0; i < FACTOR; i++) {
42 int bitposition = 1 << i; 42 int bitposition = 1 << i;
43 if ((node.dataMap & bitposition) != 0) { 43 if ((node.dataMap & bitposition) != 0) {
44 content[2 * i] = node.content[dataUsed * 2]; 44 content[2 * i] = node.content[dataUsed * 2];
@@ -54,8 +54,7 @@ public class MutableNode<K, V> extends Node<K, V> {
54 54
55 @SuppressWarnings("unchecked") 55 @SuppressWarnings("unchecked")
56 @Override 56 @Override
57 public V getValue(K key, ContinousHashProvider<? super K> hashProvider, V defaultValue, int hash, 57 public V getValue(K key, ContinousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth) {
58 int depth) {
59 int selectedHashFragment = hashFragment(hash, shiftDepth(depth)); 58 int selectedHashFragment = hashFragment(hash, shiftDepth(depth));
60 K keyCandidate = (K) this.content[2 * selectedHashFragment]; 59 K keyCandidate = (K) this.content[2 * selectedHashFragment];
61 if (keyCandidate != null) { 60 if (keyCandidate != null) {
@@ -78,8 +77,8 @@ public class MutableNode<K, V> extends Node<K, V> {
78 77
79 @SuppressWarnings("unchecked") 78 @SuppressWarnings("unchecked")
80 @Override 79 @Override
81 public Node<K, V> putValue(K key, V value, ContinousHashProvider<? super K> hashProvider, 80 public Node<K, V> putValue(K key, V value, ContinousHashProvider<? super K> hashProvider, V defaultValue, int hash,
82 V defaultValue, int hash, int depth) { 81 int depth) {
83 int selectedHashFragment = hashFragment(hash, shiftDepth(depth)); 82 int selectedHashFragment = hashFragment(hash, shiftDepth(depth));
84 K keyCandidate = (K) content[2 * selectedHashFragment]; 83 K keyCandidate = (K) content[2 * selectedHashFragment];
85 if (keyCandidate != null) { 84 if (keyCandidate != null) {
@@ -161,7 +160,7 @@ public class MutableNode<K, V> extends Node<K, V> {
161 return null; 160 return null;
162 } 161 }
163 } else { 162 } else {
164 // check whether newNode is orphan; 163 // check whether newNode is orphan
165 MutableNode<K, V> immutableNewNode = newNode.isMutable(); 164 MutableNode<K, V> immutableNewNode = newNode.isMutable();
166 if (immutableNewNode != null) { 165 if (immutableNewNode != null) {
167 int orphaned = immutableNewNode.isOrphaned(); 166 int orphaned = immutableNewNode.isOrphaned();
@@ -197,7 +196,7 @@ public class MutableNode<K, V> extends Node<K, V> {
197 196
198 protected int isOrphaned() { 197 protected int isOrphaned() {
199 int dataFound = -2; 198 int dataFound = -2;
200 for (int i = 0; i < factor; i++) { 199 for (int i = 0; i < FACTOR; i++) {
201 if (content[i * 2] != null) { 200 if (content[i * 2] != null) {
202 if (dataFound >= 0) { 201 if (dataFound >= 0) {
203 return -1; 202 return -1;
@@ -212,11 +211,10 @@ public class MutableNode<K, V> extends Node<K, V> {
212 } 211 }
213 212
214 @SuppressWarnings("unchecked") 213 @SuppressWarnings("unchecked")
215 private Node<K, V> moveDownAndSplit(ContinousHashProvider<? super K> hashProvider, K newKey, 214 private Node<K, V> moveDownAndSplit(ContinousHashProvider<? super K> hashProvider, K newKey, V newValue,
216 V newValue, K previousKey, int hashOfNewKey, int depth, int selectedHashFragmentOfCurrentDepth) { 215 K previousKey, int hashOfNewKey, int depth, int selectedHashFragmentOfCurrentDepth) {
217 V previousValue = (V) content[2 * selectedHashFragmentOfCurrentDepth + 1]; 216 V previousValue = (V) content[2 * selectedHashFragmentOfCurrentDepth + 1];
218 217
219 // final int newHash = newHash(hashProvider, newKey, hashOfNewKey, newDepth);
220 MutableNode<K, V> newSubNode = newNodeWithTwoEntries(hashProvider, previousKey, previousValue, 218 MutableNode<K, V> newSubNode = newNodeWithTwoEntries(hashProvider, previousKey, previousValue,
221 hashProvider.getHash(previousKey, hashDepth(depth)), newKey, newValue, hashOfNewKey, depth + 1); 219 hashProvider.getHash(previousKey, hashDepth(depth)), newKey, newValue, hashOfNewKey, depth + 1);
222 220
@@ -226,20 +224,14 @@ public class MutableNode<K, V> extends Node<K, V> {
226 return this; 224 return this;
227 } 225 }
228 226
229 private MutableNode<K, V> newNodeWithTwoEntries(ContinousHashProvider<? super K> hashProvider, K key1, 227 private MutableNode<K, V> newNodeWithTwoEntries(ContinousHashProvider<? super K> hashProvider, K key1, V value1,
230 V value1, int oldHash1, K key2, V value2, int oldHash2, int newdepth) { 228 int oldHash1, K key2, V value2, int oldHash2, int newdepth) {
231// final int depthLimit = 4000;
232// if(newdepth>depthLimit) {
233// final int newHashes = 4000/numberOfFactors;
234// throw new IllegalArgumentException(
235// "Continuous hash was same " + newHashes + " times for non-equivalent objects " + key1 + " and " + key2 +".");
236// }
237 int newHash1 = newHash(hashProvider, key1, oldHash1, newdepth); 229 int newHash1 = newHash(hashProvider, key1, oldHash1, newdepth);
238 int newHash2 = newHash(hashProvider, key2, oldHash2, newdepth); 230 int newHash2 = newHash(hashProvider, key2, oldHash2, newdepth);
239 int newFragment1 = hashFragment(newHash1, shiftDepth(newdepth)); 231 int newFragment1 = hashFragment(newHash1, shiftDepth(newdepth));
240 int newFragment2 = hashFragment(newHash2, shiftDepth(newdepth)); 232 int newFragment2 = hashFragment(newHash2, shiftDepth(newdepth));
241 233
242 MutableNode<K, V> subNode = new MutableNode<K, V>(); 234 MutableNode<K, V> subNode = new MutableNode<>();
243 if (newFragment1 != newFragment2) { 235 if (newFragment1 != newFragment2) {
244 subNode.content[newFragment1 * 2] = key1; 236 subNode.content[newFragment1 * 2] = key1;
245 subNode.content[newFragment1 * 2 + 1] = value1; 237 subNode.content[newFragment1 * 2 + 1] = value1;
@@ -247,8 +239,8 @@ public class MutableNode<K, V> extends Node<K, V> {
247 subNode.content[newFragment2 * 2] = key2; 239 subNode.content[newFragment2 * 2] = key2;
248 subNode.content[newFragment2 * 2 + 1] = value2; 240 subNode.content[newFragment2 * 2 + 1] = value2;
249 } else { 241 } else {
250 MutableNode<K, V> subSubNode = newNodeWithTwoEntries(hashProvider, key1, value1, newHash1, key2, 242 MutableNode<K, V> subSubNode = newNodeWithTwoEntries(hashProvider, key1, value1, newHash1, key2, value2,
251 value2, newHash2, newdepth + 1); 243 newHash2, newdepth + 1);
252 subNode.content[newFragment1 * 2 + 1] = subSubNode; 244 subNode.content[newFragment1 * 2 + 1] = subSubNode;
253 } 245 }
254 subNode.updateHash(); 246 subNode.updateHash();
@@ -270,7 +262,7 @@ public class MutableNode<K, V> extends Node<K, V> {
270 @Override 262 @Override
271 public long getSize() { 263 public long getSize() {
272 int size = 0; 264 int size = 0;
273 for (int i = 0; i < factor; i++) { 265 for (int i = 0; i < FACTOR; i++) {
274 if (content[i * 2] != null) { 266 if (content[i * 2] != null) {
275 size++; 267 size++;
276 } else { 268 } else {
@@ -297,8 +289,8 @@ public class MutableNode<K, V> extends Node<K, V> {
297 @Override 289 @Override
298 boolean moveToNext(MapCursor<K, V> cursor) { 290 boolean moveToNext(MapCursor<K, V> cursor) {
299 // 1. try to move to data 291 // 1. try to move to data
300 if (cursor.dataIndex != MapCursor.IndexFinish) { 292 if (cursor.dataIndex != MapCursor.INDEX_FINISH) {
301 for (int index = cursor.dataIndex + 1; index < factor; index++) { 293 for (int index = cursor.dataIndex + 1; index < FACTOR; index++) {
302 if (this.content[index * 2] != null) { 294 if (this.content[index * 2] != null) {
303 // 1.1 found next data 295 // 1.1 found next data
304 cursor.dataIndex = index; 296 cursor.dataIndex = index;
@@ -307,19 +299,19 @@ public class MutableNode<K, V> extends Node<K, V> {
307 return true; 299 return true;
308 } 300 }
309 } 301 }
310 cursor.dataIndex = MapCursor.IndexFinish; 302 cursor.dataIndex = MapCursor.INDEX_FINISH;
311 } 303 }
312 304
313 // 2. look inside the subnodes 305 // 2. look inside the subnodes
314 for (int index = cursor.nodeIndexStack.peek() + 1; index < factor; index++) { 306 for (int index = cursor.nodeIndexStack.peek() + 1; index < FACTOR; index++) {
315 if (this.content[index * 2] == null && this.content[index * 2 + 1] != null) { 307 if (this.content[index * 2] == null && this.content[index * 2 + 1] != null) {
316 // 2.1 found next subnode, move down to the subnode 308 // 2.1 found next subnode, move down to the subnode
317 Node<K, V> subnode = (Node<K, V>) this.content[index * 2 + 1]; 309 Node<K, V> subnode = (Node<K, V>) this.content[index * 2 + 1];
318 310
319 cursor.dataIndex = MapCursor.IndexStart; 311 cursor.dataIndex = MapCursor.INDEX_START;
320 cursor.nodeIndexStack.pop(); 312 cursor.nodeIndexStack.pop();
321 cursor.nodeIndexStack.push(index); 313 cursor.nodeIndexStack.push(index);
322 cursor.nodeIndexStack.push(MapCursor.IndexStart); 314 cursor.nodeIndexStack.push(MapCursor.INDEX_START);
323 cursor.nodeStack.push(subnode); 315 cursor.nodeStack.push(subnode);
324 316
325 return subnode.moveToNext(cursor); 317 return subnode.moveToNext(cursor);
@@ -350,7 +342,7 @@ public class MutableNode<K, V> extends Node<K, V> {
350 builder.append("Mutable("); 342 builder.append("Mutable(");
351 // print content 343 // print content
352 boolean hadContent = false; 344 boolean hadContent = false;
353 for (int i = 0; i < factor; i++) { 345 for (int i = 0; i < FACTOR; i++) {
354 if (content[2 * i] != null) { 346 if (content[2 * i] != null) {
355 if (hadContent) { 347 if (hadContent) {
356 builder.append(","); 348 builder.append(",");
@@ -366,7 +358,7 @@ public class MutableNode<K, V> extends Node<K, V> {
366 } 358 }
367 builder.append(")"); 359 builder.append(")");
368 // print subnodes 360 // print subnodes
369 for (int i = 0; i < factor; i++) { 361 for (int i = 0; i < FACTOR; i++) {
370 if (content[2 * i] == null && content[2 * i + 1] != null) { 362 if (content[2 * i] == null && content[2 * i + 1] != null) {
371 @SuppressWarnings("unchecked") 363 @SuppressWarnings("unchecked")
372 Node<K, V> subNode = (Node<K, V>) content[2 * i + 1]; 364 Node<K, V> subNode = (Node<K, V>) content[2 * i + 1];
@@ -380,14 +372,14 @@ public class MutableNode<K, V> extends Node<K, V> {
380 @Override 372 @Override
381 public void checkIntegrity(ContinousHashProvider<? super K> hashProvider, V defaultValue, int depth) { 373 public void checkIntegrity(ContinousHashProvider<? super K> hashProvider, V defaultValue, int depth) {
382 // check for orphan nodes 374 // check for orphan nodes
383 if(depth>0) { 375 if (depth > 0) {
384 int orphaned = isOrphaned(); 376 int orphaned = isOrphaned();
385 if(orphaned>=0) { 377 if (orphaned >= 0) {
386 throw new IllegalStateException("Orphaned node! " + orphaned + ": " + content[2 * orphaned]); 378 throw new IllegalStateException("Orphaned node! " + orphaned + ": " + content[2 * orphaned]);
387 } 379 }
388 } 380 }
389 // check the place of data 381 // check the place of data
390 for (int i = 0; i < factor; i++) { 382 for (int i = 0; i < FACTOR; i++) {
391 if (this.content[2 * i] != null) { 383 if (this.content[2 * i] != null) {
392 K key = (K) this.content[2 * i]; 384 K key = (K) this.content[2 * i];
393 V value = (V) this.content[2 * i + 1]; 385 V value = (V) this.content[2 * i + 1];
@@ -405,7 +397,7 @@ public class MutableNode<K, V> extends Node<K, V> {
405 } 397 }
406 } 398 }
407 // check subnodes 399 // check subnodes
408 for (int i = 0; i < factor; i++) { 400 for (int i = 0; i < FACTOR; i++) {
409 if (this.content[2 * i + 1] != null && this.content[2 * i] == null) { 401 if (this.content[2 * i + 1] != null && this.content[2 * i] == null) {
410 Node<K, V> subNode = (Node<K, V>) this.content[2 * i + 1]; 402 Node<K, V> subNode = (Node<K, V>) this.content[2 * i + 1];
411 subNode.checkIntegrity(hashProvider, defaultValue, depth + 1); 403 subNode.checkIntegrity(hashProvider, defaultValue, depth + 1);
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java
index f1efaa76..acf7a463 100644
--- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java
+++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java
@@ -5,11 +5,11 @@ import java.util.Map;
5import org.eclipse.viatra.solver.data.map.ContinousHashProvider; 5import org.eclipse.viatra.solver.data.map.ContinousHashProvider;
6 6
7public abstract class Node<K,V>{ 7public abstract class Node<K,V>{
8 public static final int branchingFactorBit = 5; 8 public static final int BRANCHING_FACTOR_BITS = 5;
9 public static final int factor = 1<<branchingFactorBit; 9 public static final int FACTOR = 1<<BRANCHING_FACTOR_BITS;
10 protected static final int numberOfFactors = Integer.SIZE / branchingFactorBit; 10 protected static final int NUMBER_OF_FACTORS = Integer.SIZE / BRANCHING_FACTOR_BITS;
11 protected static final int factorMask = factor-1; 11 protected static final int FACTOR_MASK = FACTOR-1;
12 public static final int effectiveBits = branchingFactorBit * numberOfFactors; 12 public static final int EFFECTIVE_BITS = BRANCHING_FACTOR_BITS * NUMBER_OF_FACTORS;
13 13
14 /** 14 /**
15 * Calculates the index for the continuous hash. 15 * Calculates the index for the continuous hash.
@@ -17,7 +17,7 @@ public abstract class Node<K,V>{
17 * @return The index of the continuous hash. 17 * @return The index of the continuous hash.
18 */ 18 */
19 protected static int hashDepth(int depth) { 19 protected static int hashDepth(int depth) {
20 return depth/numberOfFactors; 20 return depth/NUMBER_OF_FACTORS;
21 } 21 }
22 22
23 /** 23 /**
@@ -26,7 +26,7 @@ public abstract class Node<K,V>{
26 * @return The segment of a hash code. 26 * @return The segment of a hash code.
27 */ 27 */
28 protected static int shiftDepth(int depth) { 28 protected static int shiftDepth(int depth) {
29 return depth%numberOfFactors; 29 return depth%NUMBER_OF_FACTORS;
30 } 30 }
31 /** 31 /**
32 * Selects a segments from a complete hash for a given depth. 32 * Selects a segments from a complete hash for a given depth.
@@ -35,8 +35,8 @@ public abstract class Node<K,V>{
35 * @return The segment as an integer. 35 * @return The segment as an integer.
36 */ 36 */
37 protected static int hashFragment(int hash, int shiftDepth) { 37 protected static int hashFragment(int hash, int shiftDepth) {
38 if(shiftDepth<0 || Node.numberOfFactors<shiftDepth) throw new IllegalArgumentException("Invalid shift depth! valid intervall=[0;5], input="+shiftDepth); 38 if(shiftDepth<0 || Node.NUMBER_OF_FACTORS<shiftDepth) throw new IllegalArgumentException("Invalid shift depth! valid intervall=[0;5], input="+shiftDepth);
39 return (hash >>> shiftDepth*branchingFactorBit) & factorMask; 39 return (hash >>> shiftDepth*BRANCHING_FACTOR_BITS) & FACTOR_MASK;
40 } 40 }
41 41
42 /** 42 /**
@@ -51,15 +51,15 @@ public abstract class Node<K,V>{
51 if(hashDepth>=ContinousHashProvider.MAX_PRACTICAL_DEPTH) { 51 if(hashDepth>=ContinousHashProvider.MAX_PRACTICAL_DEPTH) {
52 throw new IllegalArgumentException("Key "+key+" have the clashing hashcode over the practical depth limitation ("+ContinousHashProvider.MAX_PRACTICAL_DEPTH+")!"); 52 throw new IllegalArgumentException("Key "+key+" have the clashing hashcode over the practical depth limitation ("+ContinousHashProvider.MAX_PRACTICAL_DEPTH+")!");
53 } 53 }
54 return depth%numberOfFactors == 0? 54 return depth%NUMBER_OF_FACTORS == 0?
55 hashProvider.getHash(key, hashDepth) : 55 hashProvider.getHash(key, hashDepth) :
56 hash; 56 hash;
57 } 57 }
58 58
59 59
60 abstract public V getValue(K key, ContinousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth); 60 public abstract V getValue(K key, ContinousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth);
61 abstract public Node<K,V> putValue(K key, V value, ContinousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth); 61 public abstract Node<K,V> putValue(K key, V value, ContinousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth);
62 abstract public long getSize(); 62 public abstract long getSize();
63 63
64 abstract MutableNode<K, V> toMutable(); 64 abstract MutableNode<K, V> toMutable();
65 public abstract ImmutableNode<K, V> toImmutable( 65 public abstract ImmutableNode<K, V> toImmutable(
@@ -73,7 +73,7 @@ public abstract class Node<K,V>{
73 abstract boolean moveToNext(MapCursor<K,V> cursor); 73 abstract boolean moveToNext(MapCursor<K,V> cursor);
74 74
75 ///////// FOR printing 75 ///////// FOR printing
76 abstract public void prettyPrint(StringBuilder builder, int depth, int code); 76 public abstract void prettyPrint(StringBuilder builder, int depth, int code);
77 @Override 77 @Override
78 public String toString() { 78 public String toString() {
79 StringBuilder stringBuilder = new StringBuilder(); 79 StringBuilder stringBuilder = new StringBuilder();
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/VersionedMapImpl.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/VersionedMapImpl.java
index d04e7117..25473fd8 100644
--- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/VersionedMapImpl.java
+++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/VersionedMapImpl.java
@@ -20,13 +20,13 @@ import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl;
20public class VersionedMapImpl<K,V> implements VersionedMap<K,V>{ 20public class VersionedMapImpl<K,V> implements VersionedMap<K,V>{
21 protected final VersionedMapStoreImpl<K,V> store; 21 protected final VersionedMapStoreImpl<K,V> store;
22 22
23 protected final ContinousHashProvider<? super K> hashProvider; 23 protected final ContinousHashProvider<K> hashProvider;
24 protected final V defaultValue; 24 protected final V defaultValue;
25 protected Node<K,V> root; 25 protected Node<K,V> root;
26 26
27 public VersionedMapImpl( 27 public VersionedMapImpl(
28 VersionedMapStoreImpl<K,V> store, 28 VersionedMapStoreImpl<K,V> store,
29 ContinousHashProvider<? super K> hashProvider, 29 ContinousHashProvider<K> hashProvider,
30 V defaultValue) 30 V defaultValue)
31 { 31 {
32 this.store = store; 32 this.store = store;
@@ -36,7 +36,7 @@ public class VersionedMapImpl<K,V> implements VersionedMap<K,V>{
36 } 36 }
37 public VersionedMapImpl( 37 public VersionedMapImpl(
38 VersionedMapStoreImpl<K,V> store, 38 VersionedMapStoreImpl<K,V> store,
39 ContinousHashProvider<? super K> hashProvider, 39 ContinousHashProvider<K> hashProvider,
40 V defaultValue, Node<K,V> data) 40 V defaultValue, Node<K,V> data)
41 { 41 {
42 this.store = store; 42 this.store = store;
@@ -48,7 +48,7 @@ public class VersionedMapImpl<K,V> implements VersionedMap<K,V>{
48 public V getDefaultValue() { 48 public V getDefaultValue() {
49 return defaultValue; 49 return defaultValue;
50 } 50 }
51 public ContinousHashProvider<? super K> getHashProvider() { 51 public ContinousHashProvider<K> getHashProvider() {
52 return hashProvider; 52 return hashProvider;
53 } 53 }
54 @Override 54 @Override
@@ -100,15 +100,14 @@ public class VersionedMapImpl<K,V> implements VersionedMap<K,V>{
100 100
101 @Override 101 @Override
102 public Cursor<K, V> getCursor() { 102 public Cursor<K, V> getCursor() {
103 MapCursor<K,V> cursor = new MapCursor<>(this.root,this); 103 return new MapCursor<>(this.root,this);
104 return cursor;
105 } 104 }
106 @Override 105 @Override
107 public DiffCursor<K, V> getDiffCursor(long toVersion) { 106 public DiffCursor<K, V> getDiffCursor(long toVersion) {
108 Cursor<K, V> fromCursor = this.getCursor(); 107 Cursor<K, V> fromCursor = this.getCursor();
109 VersionedMap<K, V> toMap = this.store.createMap(toVersion); 108 VersionedMap<K, V> toMap = this.store.createMap(toVersion);
110 Cursor<K, V> toCursor = toMap.getCursor(); 109 Cursor<K, V> toCursor = toMap.getCursor();
111 return new MapDiffCursor<K, V>(this.hashProvider,this.defaultValue, fromCursor, toCursor); 110 return new MapDiffCursor<>(this.hashProvider,this.defaultValue, fromCursor, toCursor);
112 111
113 } 112 }
114 113
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/CommitSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/CommitSmokeTest.java
index 25ad81d2..ce526534 100644
--- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/CommitSmokeTest.java
+++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/CommitSmokeTest.java
@@ -74,7 +74,7 @@ class CommitSmokeTest {
74 } 74 }
75 75
76 static Stream<Arguments> parametrizedFastSmoke() { 76 static Stream<Arguments> parametrizedFastSmoke() {
77 return SmokeTestUtils.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, 77 return SmokeTestUtils.permutationWithSize(new Object[] { SmokeTestUtils.FAST_STEP_COUNT }, new Object[] { 3, 32, 32 * 32 },
78 new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, 78 new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 },
79 new Object[] { false, true }); 79 new Object[] { false, true });
80 } 80 }
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/ContentEqualsSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/ContentEqualsSmokeTest.java
index a8202b97..2fe2a9a5 100644
--- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/ContentEqualsSmokeTest.java
+++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/ContentEqualsSmokeTest.java
@@ -1,7 +1,6 @@
1package org.eclipse.viatra.solver.data.map.tests.smoke; 1package org.eclipse.viatra.solver.data.map.tests.smoke;
2 2
3import static org.junit.jupiter.api.Assertions.assertEquals; 3import static org.junit.jupiter.api.Assertions.assertEquals;
4import static org.junit.jupiter.api.Assertions.assertTrue;
5import static org.junit.jupiter.api.Assertions.fail; 4import static org.junit.jupiter.api.Assertions.fail;
6 5
7import java.util.AbstractMap.SimpleEntry; 6import java.util.AbstractMap.SimpleEntry;
@@ -122,7 +121,7 @@ class ContentEqualsSmokeTest {
122 } 121 }
123 122
124 static Stream<Arguments> parametrizedFastSmoke() { 123 static Stream<Arguments> parametrizedFastSmoke() {
125 return SmokeTestUtils.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, 124 return SmokeTestUtils.permutationWithSize(new Object[] { SmokeTestUtils.FAST_STEP_COUNT }, new Object[] { 3, 32, 32 * 32 },
126 new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, 125 new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 },
127 new Object[] { false, true }); 126 new Object[] { false, true });
128 } 127 }
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/DiffCursorSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/DiffCursorSmokeTest.java
index c36fac47..61aa52c8 100644
--- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/DiffCursorSmokeTest.java
+++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/DiffCursorSmokeTest.java
@@ -96,7 +96,7 @@ class DiffCursorSmokeTest {
96 } 96 }
97 97
98 static Stream<Arguments> parametrizedSmoke() { 98 static Stream<Arguments> parametrizedSmoke() {
99 return SmokeTestUtils.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, 99 return SmokeTestUtils.permutationWithSize(new Object[] { SmokeTestUtils.FAST_STEP_COUNT }, new Object[] { 3, 32, 32 * 32 },
100 new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, 100 new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 },
101 new Object[] { false, true }); 101 new Object[] { false, true });
102 } 102 }
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/MutableImmutableCompareSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/MutableImmutableCompareSmokeTest.java
index ff409a66..159a761c 100644
--- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/MutableImmutableCompareSmokeTest.java
+++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/MutableImmutableCompareSmokeTest.java
@@ -67,7 +67,7 @@ class MutableImmutableCompareSmokeTest {
67 } 67 }
68 68
69 static Stream<Arguments> parametrizedFastSmoke() { 69 static Stream<Arguments> parametrizedFastSmoke() {
70 return SmokeTestUtils.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, 70 return SmokeTestUtils.permutationWithSize(new Object[] { SmokeTestUtils.FAST_STEP_COUNT }, new Object[] { 3, 32, 32 * 32 },
71 new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, 71 new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 },
72 new Object[] { false, true }); 72 new Object[] { false, true });
73 } 73 }
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/MutableSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/MutableSmokeTest.java
index 999325f0..b91e927c 100644
--- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/MutableSmokeTest.java
+++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/MutableSmokeTest.java
@@ -70,7 +70,7 @@ class MutableSmokeTest {
70 } 70 }
71 71
72 static Stream<Arguments> parametrizedSmoke() { 72 static Stream<Arguments> parametrizedSmoke() {
73 return SmokeTestUtils.permutationWithSize(new Object[] { 1000 }, 73 return SmokeTestUtils.permutationWithSize(new Object[] { SmokeTestUtils.FAST_STEP_COUNT },
74 new Object[] { 3, 32, 32 * 32, 32 * 32 * 32 * 32 }, new Object[] { 2, 3 }, new Object[] { 1, 2, 3 }, 74 new Object[] { 3, 32, 32 * 32, 32 * 32 * 32 * 32 }, new Object[] { 2, 3 }, new Object[] { 1, 2, 3 },
75 new Object[] { false, true }); 75 new Object[] { false, true });
76 } 76 }
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/RestoreSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/RestoreSmokeTest.java
index fa96f0c1..0b06a6a9 100644
--- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/RestoreSmokeTest.java
+++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/RestoreSmokeTest.java
@@ -87,7 +87,7 @@ class RestoreSmokeTest {
87 } 87 }
88 88
89 static Stream<Arguments> parametrizedFastSmoke() { 89 static Stream<Arguments> parametrizedFastSmoke() {
90 return SmokeTestUtils.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, 90 return SmokeTestUtils.permutationWithSize(new Object[] { SmokeTestUtils.FAST_STEP_COUNT }, new Object[] { 3, 32, 32 * 32 },
91 new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, 91 new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 },
92 new Object[] { false, true }); 92 new Object[] { false, true });
93 } 93 }
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/SmokeTestUtils.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/SmokeTestUtils.java
index 9eab854f..f1e5c857 100644
--- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/SmokeTestUtils.java
+++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/SmokeTestUtils.java
@@ -8,7 +8,8 @@ import java.util.stream.Stream;
8import org.junit.jupiter.params.provider.Arguments; 8import org.junit.jupiter.params.provider.Arguments;
9 9
10public final class SmokeTestUtils { 10public final class SmokeTestUtils {
11 private static final int SLOW_STEP_COUNT = 32 * 32 * 32 * 32; 11 public static final int FAST_STEP_COUNT = 1000;
12 public static final int SLOW_STEP_COUNT = 32 * 32 * 32 * 32;
12 13
13 private SmokeTestUtils() { 14 private SmokeTestUtils() {
14 throw new IllegalStateException("This is a static utility class and should not be instantiated directly"); 15 throw new IllegalStateException("This is a static utility class and should not be instantiated directly");