use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class MapEventJournalReadTask method encodeResponse.
@Override
protected ClientMessage encodeResponse(Object response) {
// we are not deserializing the whole content, only the enclosing portable. The actual items remain un
final ReadResultSetImpl resultSet = nodeEngine.getSerializationService().toObject(response);
final List<Data> items = new ArrayList<Data>(resultSet.size());
final long[] seqs = new long[resultSet.size()];
final Data[] dataItems = resultSet.getDataItems();
for (int k = 0; k < resultSet.size(); k++) {
items.add(dataItems[k]);
seqs[k] = resultSet.getSequence(k);
}
return MapEventJournalReadCodec.encodeResponse(resultSet.readCount(), items, seqs, resultSet.getNextSequenceToReadFrom());
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class CacheEventJournalReadTask method encodeResponse.
@Override
protected ClientMessage encodeResponse(Object response) {
// we are not deserializing the whole content, only the enclosing portable. The actual items remain un
final ReadResultSetImpl resultSet = nodeEngine.getSerializationService().toObject(response);
final List<Data> items = new ArrayList<Data>(resultSet.size());
final long[] seqs = new long[resultSet.size()];
final Data[] dataItems = resultSet.getDataItems();
for (int k = 0; k < resultSet.size(); k++) {
items.add(dataItems[k]);
seqs[k] = resultSet.getSequence(k);
}
return CacheEventJournalReadCodec.encodeResponse(resultSet.readCount(), items, seqs, resultSet.getNextSequenceToReadFrom());
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ClientMapProxy method readFromEventJournal.
@Override
public <T> InternalCompletableFuture<ReadResultSet<T>> readFromEventJournal(long startSequence, int minSize, int maxSize, int partitionId, java.util.function.Predicate<? super EventJournalMapEvent<K, V>> predicate, java.util.function.Function<? super EventJournalMapEvent<K, V>, ? extends T> projection) {
if (maxSize < minSize) {
throw new IllegalArgumentException("maxSize " + maxSize + " must be greater or equal to minSize " + minSize);
}
final SerializationService ss = getSerializationService();
final ClientMessage request = MapEventJournalReadCodec.encodeRequest(name, startSequence, minSize, maxSize, ss.toData(predicate), ss.toData(projection));
final ClientInvocationFuture fut = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
return new ClientDelegatingFuture<>(fut, ss, message -> {
MapEventJournalReadCodec.ResponseParameters params = MapEventJournalReadCodec.decodeResponse(message);
ReadResultSetImpl resultSet = new ReadResultSetImpl<>(params.readCount, params.items, params.itemSeqs, params.nextSeq);
resultSet.setSerializationService(getSerializationService());
return resultSet;
});
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenMinimumNumberOfItemsAvailable.
@Test
public void whenMinimumNumberOfItemsAvailable() {
long startSequence = ringbuffer.tailSequence() + 1;
ReadManyOperation op = getReadManyOperation(startSequence, 3, 3, null);
ringbuffer.add("item1");
ringbuffer.add("item2");
ringbuffer.add("item3");
assertFalse(op.shouldWait());
ReadResultSetImpl response = getReadResultSet(op);
assertEquals(startSequence + 3, op.sequence);
assertEquals(asList("item1", "item2", "item3"), response);
assertEquals(3, response.getNextSequenceToReadFrom());
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenEnoughItemsAvailable.
@Test
public void whenEnoughItemsAvailable() {
long startSequence = ringbuffer.tailSequence() + 1;
ReadManyOperation op = getReadManyOperation(startSequence, 1, 3, null);
ringbuffer.add("item1");
ringbuffer.add("item2");
ringbuffer.add("item3");
ringbuffer.add("item4");
ringbuffer.add("item5");
assertFalse(op.shouldWait());
ReadResultSetImpl response = getReadResultSet(op);
assertEquals(startSequence + 3, op.sequence);
assertEquals(asList("item1", "item2", "item3"), response);
assertEquals(3, response.readCount());
assertEquals(3, response.getNextSequenceToReadFrom());
}
Aggregations