dschneider-pivotal commented on a change in pull request #6768:
URL: https://github.com/apache/geode/pull/6768#discussion_r697727531



##########
File path: 
geode-apis-compatible-with-redis/src/test/java/org/apache/geode/redis/internal/collections/SizeableBytes2ObjectOpenCustomHashMapWithCursorTest.java
##########
@@ -78,23 +66,58 @@ protected int sizeValue(String value) {
     }
   }
 
+  private static byte[] makeKey(Integer i) {
+    return i.toString().getBytes();
+  }
+
   @Test
   public void scanEntireMap_ReturnsExpectedElements() {
-    Integer2StringMap map = new Integer2StringMap();
-    IntStream.range(0, 10).forEach(i -> map.put(i, "value-" + i));
+    Bytes2StringMap map = new Bytes2StringMap();
+    IntStream.range(0, 10).forEach(i -> map.put(makeKey(i), "value-" + i));
 
-    Map<Integer, String> scanned = new HashMap<>();
+    Map<byte[], String> scanned = new 
Object2ObjectOpenCustomHashMap<>(ByteArrays.HASH_STRATEGY);
     int result = map.scan(0, 10000, Map::put, scanned);
     assertThat(result).isEqualTo(0);
     assertThat(scanned).isEqualTo(map);
   }
 
+  private void fillMapWithUniqueHashKeys(Bytes2StringMap map, int keysToAdd) {
+    int keyCounter = 0;
+    Set<Integer> hashesAdded = new HashSet<>();
+    while (keysToAdd > 0) {
+      byte[] key = makeKey(keyCounter);
+      int keyHash = map.hash(key);
+      if (!hashesAdded.contains(keyHash)) {
+        hashesAdded.add(keyHash);
+        map.put(key, "value-" + keyCounter);
+        keysToAdd--;
+      }
+      keyCounter++;
+    }
+  }
+
+  private void fillMapWithCollidingHashKeys(Bytes2StringMap map, int 
keysToAdd) {
+    int keyCounter = 0;
+    Set<Integer> hashesAdded = new HashSet<>();
+    while (keysToAdd > 0) {
+      byte[] key = makeKey(keyCounter);
+      int keyHash = map.hash(key);
+      if (hashesAdded.isEmpty() || hashesAdded.contains(keyHash)) {
+        hashesAdded.add(keyHash);
+        map.put(key, "value-" + keyCounter);
+        keysToAdd--;
+        System.out.println("adding key " + keyCounter);

Review comment:
       yes




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to