Interface RowSequence

All Superinterfaces:
AutoCloseable, LongSizedDataStructure, SafeCloseable
All Known Subinterfaces:
RowSet, SingleRangeMixin, TrackingRowSet, TrackingWritableRowSet, WritableRowSet
All Known Implementing Classes:
RowSequenceAsChunkImpl, RowSequenceKeyRangesChunkImpl, RowSequenceRowKeysChunkImpl, RspRowSequence, ShiftedRowSequence, SingleRangeRowSequence, SortedRangesRowSequence, TrackingWritableRowSetImpl, WritableRowSetImpl

public interface RowSequence extends SafeCloseable, LongSizedDataStructure
An ordered collection of long row keys.
  • Field Details

  • Method Details

    • getRowSequenceIterator

      RowSequence.Iterator getRowSequenceIterator()
      Get an RowSequence.Iterator over this RowSequence.
      Returns:
      A new iterator, positioned at the first row key
    • getRowSequenceByPosition

      RowSequence getRowSequenceByPosition(long startPositionInclusive, long length)

      Get an ordered subset of the row keys in this RowSequence for a position range. The result will contain the set of row keys in this that lie at positions in the half-open range [startPositionInclusive, startPositionInclusive + length). The returned reference is owned by the caller, who should call close() when it is done with it.

      Parameters:
      startPositionInclusive - The position of the first row key to include
      length - The number of row keys to include
      Returns:
      The subset as an RowSequence, which may be this
    • getRowSequenceByKeyRange

      RowSequence getRowSequenceByKeyRange(long startRowKeyInclusive, long endRowKeyInclusive)

      Get an ordered subset of the row keys in this RowSequence for a row key range. The returned set will be the intersection of the row keys in this with the row keys in the closed interval [startRowKeyInclusive, endRowKeyInclusive]. The returned reference is owned by the caller, who should call close() when it is done with it.

      Parameters:
      startRowKeyInclusive - The minimum row key to include
      endRowKeyInclusive - The maximum row key to include
      Returns:
      The subset as an RowSequence, which may be this
    • asRowSet

      RowSet asRowSet()
      Get a RowSet representation of this RowSequence.
      Returns:
      A RowSet representation for the same row keys in the same order
      ApiNote:
      If you use the result across clock ticks, you may observe inconsistencies. You must not mutate the result. You must close the result.
    • asRowKeyChunk

      LongChunk<OrderedRowKeys> asRowKeyChunk()
      Get a LongChunk representation of the individual row keys in this RowSequence.
      Returns:
      A LongChunk containing the row keys in this RowSequence
      ApiNote:
      This RowSequence owns the result, which is valid only as long as this RowSequence remains valid. You must not mutate the result.
    • asRowKeyRangesChunk

      LongChunk<OrderedRowKeyRanges> asRowKeyRangesChunk()
      Get a LongChunk representation of row key ranges in this RowSequence.
      Returns:
      A LongChunk containing the row key ranges in this RowSequence
      ApiNote:
      This RowSequence owns the result, which is valid only as long as this RowSequence remains valid. You must not mutate the result.
    • fillRowKeyChunk

      void fillRowKeyChunk(WritableLongChunk<? super OrderedRowKeys> chunkToFill)

      Fill the supplied WritableLongChunk with individual row keys from this RowSequence.

      The chunk's capacity is assumed to be big enough.

      Parameters:
      chunkToFill - A chunk to fill with individual row keys
    • fillRowKeyRangesChunk

      void fillRowKeyRangesChunk(WritableLongChunk<OrderedRowKeyRanges> chunkToFill)

      Fill the supplied WritableLongChunk with row key ranges from this RowSequence.

      The chunk's capacity is assumed to be big enough.

      Parameters:
      chunkToFill - A chunk to fill with row key ranges
    • isEmpty

      boolean isEmpty()
      True if the size of this RowSequence is zero.
      Returns:
      True if there are no elements in this RowSequence.
    • firstRowKey

      long firstRowKey()
      Get the first row key in this RowSequence.
      Returns:
      The first row key, or NULL_ROW_KEY if there is none.
    • lastRowKey

      long lastRowKey()
      Get the last row key in this RowSequence.
      Returns:
      The last row key, or NULL_ROW_KEY if there is none.
    • size

      long size()
      Get the number of row keys in this RowSequence.
      Specified by:
      size in interface LongSizedDataStructure
      Returns:
      The size, in [0, Long.MAX_VALUE]
    • isContiguous

      default boolean isContiguous()
      Helper to tell you if this is one contiguous range.
    • getAverageRunLengthEstimate

      long getAverageRunLengthEstimate()

      Get an estimate of the average (mean) length of runs of adjacent row keys in this RowSequence.

      Implementations should strive to keep this method efficient (O(1) preferred) at the expense of accuracy.

      Empty RowSequence should return an arbitrary valid value, usually 1.

      Returns:
      An estimate of the average run length in this RowSequence, in [1, size()]
    • forEachRowKey

      boolean forEachRowKey(LongAbortableConsumer lac)
      For as long as the consumer wants more row keys, call accept on the consumer with the individual row key instances in this RowSequence, in increasing order.
      Parameters:
      lac - a consumer to feed the individual row key values to.
      Returns:
      false if the consumer provided ever returned false, true otherwise.
    • forEachRowKeyRange

      boolean forEachRowKeyRange(LongRangeAbortableConsumer larc)
      For as long as the consumer wants more ranges, call accept on the consumer with the individual row key ranges in this RowSequence, in increasing order.
      Parameters:
      larc - a consumer to feed the individual row key values to.
      Returns:
      false if the consumer provided ever returned false, true otherwise.
    • forAllRowKeys

      default void forAllRowKeys(LongConsumer lc)
    • forAllRowKeyRanges

      default void forAllRowKeyRanges(LongRangeConsumer lrc)
    • close

      default void close()

      Free any resources associated with this object.

      Using any RowSequence 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