Search in sources :

Example 1 with SampleableConcurrentHashMap

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);
    }
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SampleableConcurrentHashMap(com.hazelcast.util.SampleableConcurrentHashMap) ArrayList(java.util.ArrayList) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) Test(org.junit.Test)

Aggregations

DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)1 Data (com.hazelcast.nio.serialization.Data)1 SerializationService (com.hazelcast.spi.serialization.SerializationService)1 SampleableConcurrentHashMap (com.hazelcast.util.SampleableConcurrentHashMap)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1