Interface RowSequence.Iterator

All Superinterfaces:
AutoCloseable, SafeCloseable
Enclosing interface:
RowSequence

public static interface RowSequence.Iterator extends SafeCloseable
Iterator for consuming an RowSequence by ordered subsets.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    advance(long nextKey)
    Advance this iterator's position to nextKey, or to the first present row key greater than nextKey if nextKey is not found.
    default long
    Advance this iterator's position as in advance(long), returning the number of row keys thus consumed.
    default void
    Free any resources associated with this iterator.
    getNextRowSequenceThrough(long maxKeyInclusive)
    Get a RowSequence from the row key at the position of this iterator up to the maximum row key (inclusive).
    getNextRowSequenceWithLength(long numberOfKeys)
    Get a RowSequence from the row key at the position of this iterator up to the desired number of row keys.
    long
    Taking the difference between values returned by this method at different positions in the iterator gives you the cardinality of the set of row keys between them, exclusive.
    boolean
    Poll whether there are more row keys available from this RowSequence.Iterator.
    long
    Peek at the next row key that would be returned by getNextRowSequenceThrough(long) or getNextRowSequenceWithLength(long).
  • Method Details

    • hasMore

      boolean hasMore()
      Poll whether there are more row keys available from this RowSequence.Iterator.
      Returns:
      True if there are more row keys available, else false
    • peekNextKey

      long peekNextKey()
      Peek at the next row key that would be returned by getNextRowSequenceThrough(long) or getNextRowSequenceWithLength(long). Does not advance the position.
      Returns:
      The next row key that would be returned, or RowSequence.NULL_ROW_KEY if this iterator is exhausted
    • getNextRowSequenceThrough

      RowSequence getNextRowSequenceThrough(long maxKeyInclusive)
      Get a RowSequence from the row key at the position of this iterator up to the maximum row key (inclusive). Advances the position of this iterator by the size of the result. If the maximum row key provided is smaller than the next row key (as would be returned by peekNextKey()), the empty RowSequence is returned. The returned RowSequence object is only borrowed by the caller from the RowSequence.Iterator, who owns it. It is guaranteed to be valid and not change only until a later call to another getNext* method. As the returned reference is owned by the RowSequence.Iterator, the caller should not call close() on it.
      Parameters:
      maxKeyInclusive - The maximum row key to include.
      Returns:
      An RowSequence from the row key at the initial position up to the maximum row key (inclusive).
    • getNextRowSequenceWithLength

      RowSequence getNextRowSequenceWithLength(long numberOfKeys)
      Get a RowSequence from the row key at the position of this iterator up to the desired number of row keys. Advances the position of this iterator by the size of the result. The returned RowSequence object is only borrowed by the caller from the RowSequence.Iterator, who owns it. It is guaranteed to be valid and not change only until the next call to another getNext* method. As the returned reference is owned by the RowSequence.Iterator, the caller should not call close() on it.
      Parameters:
      numberOfKeys - The desired number of row keys
      Returns:
      An RowSequence from the row key at the initial position up to the desired number of row keys
    • advance

      boolean advance(long nextKey)

      Advance this iterator's position to nextKey, or to the first present row key greater than nextKey if nextKey is not found. If nextKey is less than or equal to the row key at this iterator's current position, this method is a no-op.

      Subsequent calls to peekNextKey(), getNextRowSequenceThrough(long), or getNextRowSequenceWithLength(long) will begin with the row key advanced to.

      Parameters:
      nextKey - The row key to advance to
      Returns:
      true If there are any row keys remaining to be iterated after the advance, false if this RowSequence.Iterator is exhausted
    • advanceAndGetPositionDistance

      default long advanceAndGetPositionDistance(long nextKey)
      Advance this iterator's position as in advance(long), returning the number of row keys thus consumed.
      Parameters:
      nextKey - The row key to advance to
      Returns:
      The number of row keys consumed from the iterator
    • close

      default void close()

      Free any resources associated with this iterator.

      Callers of RowSequence.getRowSequenceIterator() are responsible for ensuring that close() is called when they are done with resulting RowSequence.Iterator.

      Using any RowSequence.Iterator methods after close() is an error and may produce exceptions or undefined results.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface SafeCloseable
    • getRelativePosition

      long getRelativePosition()
      Taking the difference between values returned by this method at different positions in the iterator gives you the cardinality of the set of row keys between them, exclusive. Note a single value itself is not meaningful; like measuring elapsed time, it only makes sense to take the difference from absolute points.
      Returns:
      A relative position offset from some arbitrary initial point in the underlying row sequence.