use of com.hazelcast.internal.util.SampleableConcurrentHashMap in project hazelcast by hazelcast.
the class CacheBasicAbstractTest method testInitableIterator.
@Test
public void testInitableIterator() {
int testSize = 3007;
SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
for (int fetchSize = 1; fetchSize < 102; fetchSize++) {
SampleableConcurrentHashMap<Data, String> map = new SampleableConcurrentHashMap<>(1000);
for (int i = 0; i < testSize; i++) {
Integer key = i;
Data data = serializationService.toData(key);
String value1 = "value" + i;
map.put(data, value1);
}
IterationPointer[] pointers = { new IterationPointer(Integer.MAX_VALUE, -1) };
int total = 0;
int remaining = testSize;
while (remaining > 0 && pointers[pointers.length - 1].getIndex() > 0) {
int size = (Math.min(remaining, fetchSize));
List<Data> keys = new ArrayList<>(size);
pointers = map.fetchKeys(pointers, size, keys);
remaining -= keys.size();
total += keys.size();
}
assertEquals(testSize, total);
}
}
Aggregations