Interface ReadResultSet<E>

Type Parameters:
E - item type
All Superinterfaces:
Iterable<E>

public interface ReadResultSet<E> extends Iterable<E>
The result of a Ringbuffer.readManyAsync(long, int, int, com.hazelcast.core.IFunction) operation.

Important:
If an item is retrieved multiple times from the result set, a new instance is returned for every invocation. This is done to prevent unexpected sharing if the CompletionStage is shared between multiple threads.

Since:
3.5
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Value returned from methods returning a sequence number when the information is not available (e.g. because of rolling upgrade and some members not returning the sequence).
  • Method Summary

    Modifier and Type
    Method
    Description
    get(int index)
    Gets the item at the given index.
    long
    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.
    int
    Returns the number of items that have been read before filtering.
    int
    Return the result set size.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Field Details

    • SEQUENCE_UNAVAILABLE

      static final int SEQUENCE_UNAVAILABLE
      Value returned from methods returning a sequence number when the information is not available (e.g. because of rolling upgrade and some members not returning the sequence).
      See Also:
  • Method Details

    • readCount

      int readCount()
      Returns the number of items that have been read before filtering.

      If no filter is set, then the readCount will be equal to 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 size(). Otherwise, you will be re-reading the same filtered messages.

      Returns:
      the number of items read (including the filtered ones).
    • get

      E get(int index)
      Gets the item at the given index.
      Parameters:
      index - the index
      Returns:
      the found item.
      Throws:
      IllegalArgumentException - if index out of bounds.
    • getSequence

      long getSequence(int index)
      Return the sequence number for the item at the given index.
      Parameters:
      index - the index
      Returns:
      the sequence number for the ringbuffer item
      Throws:
      IllegalArgumentException - if index out of bounds.
      Since:
      3.9
      See Also:
    • size

      int size()
      Return the result set size. See also readCount().
      Returns:
      the result set size
      Since:
      3.9
    • getNextSequenceToReadFrom

      long getNextSequenceToReadFrom()
      Returns the sequence of the item following the last read item. This sequence can then be used to read items following the ones returned by this result set. Usually this sequence is equal to the sequence used to retrieve this result set incremented by the 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.
      Returns:
      the sequence of the item following the last item in the result set
      Since:
      3.10