use of com.hazelcast.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<Data, String>(1000);
for (int i = 0; i < testSize; i++) {
Integer key = i;
Data data = serializationService.toData(key);
String value1 = "value" + i;
map.put(data, value1);
}
int nextTableIndex = Integer.MAX_VALUE;
int total = 0;
int remaining = testSize;
while (remaining > 0 && nextTableIndex > 0) {
int size = (remaining > fetchSize ? fetchSize : remaining);
List<Data> keys = new ArrayList<Data>(size);
nextTableIndex = map.fetchKeys(nextTableIndex, size, keys);
remaining -= keys.size();
total += keys.size();
}
assertEquals(testSize, total);
}
}
Aggregations