eolivelli commented on a change in pull request #3061:
URL: https://github.com/apache/bookkeeper/pull/3061#discussion_r808897847
##########
File path:
bookkeeper-server/src/test/java/org/apache/bookkeeper/util/collections/ConcurrentLongLongPairHashMapTest.java
##########
@@ -113,6 +113,22 @@ public void testRemove() {
assertTrue(map.isEmpty());
}
+ @Test
+ public void testExpandAndShrink() {
+ ConcurrentLongLongPairHashMap map = new
ConcurrentLongLongPairHashMap(2, 1);
+ assertTrue(map.put(1, 1, 11, 11));
+ assertTrue(map.put(2, 2, 22, 22));
+ assertTrue(map.put(3, 3, 33, 33));
+
+ // expand hashmap
+ assertTrue(map.capacity() == 8);
+
+ assertTrue(map.remove(1, 1, 11, 11));
+ assertTrue(map.remove(2, 2, 22, 22));
+ // shrink hashmap
+ assertTrue(map.capacity() == 4);
Review comment:
Can we also verify that the map is able to expand again?
Also, we should also verify that the map does not keep shrinking at every
remove() operation
Here in the test case we have to ensure that the behaviour is as expected
##########
File path:
bookkeeper-server/src/test/java/org/apache/bookkeeper/util/collections/ConcurrentLongLongPairHashMapTest.java
##########
@@ -113,6 +113,22 @@ public void testRemove() {
assertTrue(map.isEmpty());
}
+ @Test
+ public void testExpandAndShrink() {
+ ConcurrentLongLongPairHashMap map = new
ConcurrentLongLongPairHashMap(2, 1);
+ assertTrue(map.put(1, 1, 11, 11));
+ assertTrue(map.put(2, 2, 22, 22));
+ assertTrue(map.put(3, 3, 33, 33));
+
+ // expand hashmap
+ assertTrue(map.capacity() == 8);
+
+ assertTrue(map.remove(1, 1, 11, 11));
Review comment:
Please assert that the map did not shrink here, otherwise we cannot
state when it shrank
--
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]