O - deserialized ringbuffer typeE - result set type, is equal to O if the projection
is null or returns the same type as the parameterpublic class ReadResultSetImpl<O,E> extends AbstractList<E> implements IdentifiedDataSerializable, HazelcastInstanceAware, ReadResultSet<E>, Versioned
ReadManyOperation.
The problem with a regular list is that if you store Data objects, then
on the receiving side you get a list with data objects. If you hand this
list out to the caller, you have a problem because he sees data objects
instead of deserialized objects.
The predicate, filter and projection may be null in which case
all elements are returned and no projection is applied.
| Modifier and Type | Field and Description |
|---|---|
protected SerializationService |
serializationService |
modCountSEQUENCE_UNAVAILABLE| Constructor and Description |
|---|
ReadResultSetImpl() |
ReadResultSetImpl(int minSize,
int maxSize,
SerializationService serializationService,
IFunction<O,Boolean> filter) |
ReadResultSetImpl(int minSize,
int maxSize,
SerializationService serializationService,
Predicate<? super O> predicate,
Projection<? super O,E> projection) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Object o) |
void |
addItem(long seq,
Object item)
Applies the
Projection and adds an item to this ReadResultSetImpl if
it passes the Predicate and IFunction with which it was constructed. |
E |
get(int index)
Gets the item at the given index.
|
Data[] |
getDataItems() |
int |
getFactoryId()
Returns DataSerializableFactory factory ID for this class.
|
int |
getId()
Returns type identifier for this class.
|
long |
getNextSequenceToReadFrom()
Returns the sequence of the item following the last read item.
|
long |
getSequence(int index)
Return the sequence number for the item at the given index.
|
boolean |
isMaxSizeReached() |
boolean |
isMinSizeReached() |
int |
readCount()
Returns the number of items that have been read before filtering.
|
void |
readData(ObjectDataInput in)
Reads fields from the input stream
|
void |
setHazelcastInstance(HazelcastInstance hz)
Gets the HazelcastInstance reference when submitting a Runnable/Callable using Hazelcast ExecutorService.
|
void |
setNextSequenceToReadFrom(long nextSeq) |
void |
setSerializationService(SerializationService serializationService) |
int |
size()
Return the result set size.
|
void |
writeData(ObjectDataOutput out)
Writes object fields to output stream
|
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, iterator, spliteratoraddAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArrayparallelStream, removeIf, streamprotected transient SerializationService serializationService
public ReadResultSetImpl()
public ReadResultSetImpl(int minSize,
int maxSize,
SerializationService serializationService,
IFunction<O,Boolean> filter)
public ReadResultSetImpl(int minSize,
int maxSize,
SerializationService serializationService,
Predicate<? super O> predicate,
Projection<? super O,E> projection)
public boolean isMaxSizeReached()
public boolean isMinSizeReached()
public Data[] getDataItems()
public int readCount()
ReadResultSet
If no filter is set, then the readCount will be equal to
ReadResultSet.size().
But if a filter is applied, it could be that items are read, but are
filtered out. So if you are trying to make another read based on the
ReadResultSet then you should increment the sequence by
readCount and not by ReadResultSet.size().
Otherwise you will be re-reading the same filtered messages.
readCount in interface ReadResultSet<E>public void setHazelcastInstance(HazelcastInstance hz)
HazelcastInstanceAwaresetHazelcastInstance in interface HazelcastInstanceAwarehz - the HazelcastInstance referencepublic void setSerializationService(SerializationService serializationService)
public E get(int index)
ReadResultSetget in interface ReadResultSet<E>get in interface List<E>get in class AbstractList<E>index - the indexpublic long getSequence(int index)
ReadResultSetgetSequence in interface ReadResultSet<E>index - the indexCluster.getClusterVersion()public void addItem(long seq,
Object item)
Projection and adds an item to this ReadResultSetImpl if
it passes the Predicate and IFunction with which it was constructed.
The item may be in serialized or deserialized format as this method will
adapt the parameter if necessary before providing it to the predicate and projection.
If the item is in Data format and there is no filter, predicate or projection,
the item is added to the set without any additional serialization or deserialization.
seq - the sequence ID of the itemitem - the item to add to the result setpublic boolean add(Object o)
add in interface Collection<E>add in interface List<E>add in class AbstractList<E>public int size()
ReadResultSetReadResultSet.readCount().size in interface ReadResultSet<E>size in interface Collection<E>size in interface List<E>size in class AbstractCollection<E>public int getFactoryId()
IdentifiedDataSerializablegetFactoryId in interface IdentifiedDataSerializablepublic int getId()
IdentifiedDataSerializablegetId in interface IdentifiedDataSerializablepublic long getNextSequenceToReadFrom()
ReadResultSetReadResultSet.readCount(). In cases when the
reader tolerates lost items, this is not the case.
For instance, if the reader requests an item with a stale sequence (one
which has already been overwritten), the read will jump to the oldest
sequence and read from there.
Similarly, if the reader requests an item in the future (e.g. because
the partition was lost and the reader was unaware of this), the read
method will jump back to the newest available sequence.
Because of these jumps and only in the case when the reader is loss
tolerant, the next sequence must be retrieved using this method.
A return value of -1 means that the
information is not available.getNextSequenceToReadFrom in interface ReadResultSet<E>public void setNextSequenceToReadFrom(long nextSeq)
public void writeData(ObjectDataOutput out) throws IOException
DataSerializablewriteData in interface DataSerializableout - outputIOException - if an I/O error occurs. In particular,
an IOException may be thrown if the
output stream has been closed.public void readData(ObjectDataInput in) throws IOException
DataSerializablereadData in interface DataSerializablein - inputIOException - if an I/O error occurs. In particular,
an IOException may be thrown if the
input stream has been closed.Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.