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());
}
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);
}
Aggregations