Search in sources :

Example 1 with DefaultCyclicBuffer

use of com.hazelcast.map.impl.querycache.accumulator.DefaultCyclicBuffer in project hazelcast by hazelcast.

the class CyclicBufferTest method testBufferSize_whenEmpty.

@Test
public void testBufferSize_whenEmpty() {
    int maxCapacity = nextPowerOfTwo(10);
    CyclicBuffer buffer = new DefaultCyclicBuffer(maxCapacity);
    assertEquals("item count should be = " + 0, 0, buffer.size());
}
Also used : DefaultCyclicBuffer(com.hazelcast.map.impl.querycache.accumulator.DefaultCyclicBuffer) DefaultCyclicBuffer(com.hazelcast.map.impl.querycache.accumulator.DefaultCyclicBuffer) CyclicBuffer(com.hazelcast.map.impl.querycache.accumulator.CyclicBuffer) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with DefaultCyclicBuffer

use of com.hazelcast.map.impl.querycache.accumulator.DefaultCyclicBuffer in project hazelcast by hazelcast.

the class CyclicBufferTest method testBufferRead_withSequence.

@Test
public void testBufferRead_withSequence() {
    int maxCapacity = nextPowerOfTwo(10);
    int itemCount = 4;
    CyclicBuffer<TestSequenced> buffer = new DefaultCyclicBuffer<TestSequenced>(maxCapacity);
    for (int i = 1; i <= itemCount; i++) {
        buffer.add(new TestSequenced(i));
    }
    long readFromSequence = 1L;
    do {
        Sequenced sequenced = buffer.get(readFromSequence);
        if (sequenced == null) {
            break;
        }
        if (readFromSequence + 1 > itemCount) {
            break;
        }
        readFromSequence++;
    } while (true);
    assertEquals("read count should be = " + readFromSequence, readFromSequence, itemCount);
}
Also used : Sequenced(com.hazelcast.map.impl.querycache.event.sequence.Sequenced) DefaultCyclicBuffer(com.hazelcast.map.impl.querycache.accumulator.DefaultCyclicBuffer) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

DefaultCyclicBuffer (com.hazelcast.map.impl.querycache.accumulator.DefaultCyclicBuffer)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 CyclicBuffer (com.hazelcast.map.impl.querycache.accumulator.CyclicBuffer)1 Sequenced (com.hazelcast.map.impl.querycache.event.sequence.Sequenced)1