Interface RowSet

All Superinterfaces:
AutoCloseable, LogOutputAppendable, LongSizedDataStructure, RowSequence, SafeCloseable
All Known Subinterfaces:
TrackingRowSet, TrackingWritableRowSet, WritableRowSet
All Known Implementing Classes:
TrackingWritableRowSetImpl, WritableRowSetImpl

RowSequence with additional set and set-like capabilities.
  • Field Details

  • Method Details

    • close

      default void close()

      Free any resources associated with this object.

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

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface RowSequence
      Specified by:
      close in interface SafeCloseable
    • copy

      Make a new WritableRowSet with the same row keys as this that is safe for further mutation. As in other operations that return a WritableRowSet, the result must be closed by the caller when it is no longer needed. The result will never be a TrackingRowSet; use WritableRowSet.toTracking() on the result as needed.
      Returns:
      The copied WritableRowSet
    • size

      long size()
      How many keys are in this RowSet.
      Specified by:
      size in interface LongSizedDataStructure
      Specified by:
      size in interface RowSequence
      Returns:
      the number of keys in this RowSet.
    • isEmpty

      boolean isEmpty()
      Queries whether this RowSet is empty (i.e. has no keys).
      Specified by:
      isEmpty in interface RowSequence
      Returns:
      true if the size() of this RowSet is zero, false if the size is greater than zero
    • isNonempty

      default boolean isNonempty()
      Queries whether this RowSet is non-empty (i.e. has at least one key).
      Returns:
      true if the size() of this RowSet greater than zero, false if the size is zero
    • isFlat

      default boolean isFlat()
      Returns whether or not this RowSet is flat. Unlike a table, this is a mutable property; which may change from step to step.
      Returns:
      true if the RowSet keys are contiguous and start at zero.
    • firstRowKey

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

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

      default WritableRowSet invert(RowSet keys)

      Returns a WritableRowSet with the row positions of keys in this RowSet.

      This can be thought of as an iterative find() over the values in keys, but all keys must exist within this RowSet, because a RowSet result can not represent negative values.

      Parameters:
      keys - The keys to find positions for
      Returns:
      A new WritableRowSet containing the positions of the keys in this RowSet
    • invert

      WritableRowSet invert(RowSet keys, long maximumPosition)

      Returns the row positions of keys in the current set as a WritableRowSet, stopping at maximumPosition.

      This can be thought of as an iterative find(long) over the values in keys, but all keys must exist within this RowSet, because a RowSet result can not represent negative values.

      Parameters:
      keys - The keys to find positions for
      maximumPosition - The largest position for which we will find a key
      Returns:
      A new WritableRowSet containing the positions of the keys in this RowSet
    • intersect

      @NotNull @NotNull WritableRowSet intersect(@NotNull @NotNull RowSet range)
      Returns a new RowSet representing the intersection of the current RowSet with the input RowSet
    • overlaps

      boolean overlaps(@NotNull @NotNull RowSet rowSet)
      Returns true if a RowSet has any overlap.
    • overlapsRange

      boolean overlapsRange(long start, long end)
      Returns true if this RowSet has any overlap with the provided range.
      Parameters:
      start - Start of range, inclusive.
      end - End of range, inclusive.
      Returns:
      true if any value x in start <= x <= end is contained in this RowSet.
    • subsetOf

      boolean subsetOf(@NotNull @NotNull RowSet other)
      Returns true if this RowSet is a (possibly improper) subset of other.
      Returns:
      true if every element of this exists within other
    • minus

      WritableRowSet minus(RowSet rowSetToRemove)
      Returns a new RowSet representing the keys of the current set not present inside rowSetToRemove. This operation is equivalent to set difference. This RowSet is not modified.
    • union

      WritableRowSet union(RowSet rowSetToAdd)
      Returns a new RowSet representing the keys present in both this RowSet and the argument RowSet.
      Parameters:
      rowSetToAdd - A RowSet whose keys will be joined with our own to produce a new RowSet.
      Returns:
      a new RowSet with the union of the keys in both this RowSet and rowSetToAdd.
    • shift

      WritableRowSet shift(long shiftAmount)
    • forEachRowKey

      boolean forEachRowKey(LongAbortableConsumer lc)
      Provide each value contained in this RowSet, in increased sorted order to the consumer. If the consumer returns false for a key, stops after that key (does not provide any keys after that key).
      Specified by:
      forEachRowKey in interface RowSequence
      Parameters:
      lc - the consumer.
      Returns:
      false if the consumer returned false at some point, true if the consumer always returned true and all values in the RowSet were consumed.
    • forAllRowKeys

      default void forAllRowKeys(LongConsumer lc)
      Specified by:
      forAllRowKeys in interface RowSequence
    • toRowKeyArray

      default void toRowKeyArray(long[] vs)
    • toRowKeyArray

      default void toRowKeyArray(long[] vs, int offset)
    • subSetByPositionRange

      WritableRowSet subSetByPositionRange(long startPos, long endPos)
      Get a subset of this RowSet within the specified half-closed range of row positions.
      Parameters:
      startPos - The first position to included in the output (inclusive)
      endPos - The last position to included in the output (exclusive)
      Returns:
      A new RowSet, containing only positions >= startPos and < endPos
    • subSetByKeyRange

      WritableRowSet subSetByKeyRange(long startKey, long endKey)
      Get a subset of this RowSet within the specified closed range of row keys.
      Parameters:
      startKey - The first key to include in the output.
      endKey - The last key (inclusive) to include in the output.
      Returns:
      A new RowSet, containing only values >= startKey and <= endKey.
    • subSetForPositions

      WritableRowSet subSetForPositions(RowSequence posRowSequence, boolean reversed)
      Get a subset of this RowSet according to the supplied sequence of row positions in posRowSequence.
      Parameters:
      posRowSequence - The RowSequence of positions ranges to get (as in get(long))
      reversed - Whether to treat posRowSet as offsets relative to size() rather than 0
      Returns:
      A new RowSet, containing the row keys from this RowSet at the row positions in posRowSequence
    • subSetForPositions

      WritableRowSet subSetForPositions(RowSequence posRowSequence)
      Get a subset of this RowSet according to the supplied sequence of row positions in posRowSequence.
      Parameters:
      posRowSequence - The RowSequence of position-based ranges to extract.
      Returns:
      A new RowSet, containing values at the locations in the provided RowSet.
    • subSetForReversePositions

      WritableRowSet subSetForReversePositions(RowSequence posRowSequence)
      Get a subset of this RowSet according to the supplied sequence of row positions relative to size() in posRowSequence.
      Parameters:
      posRowSequence - The RowSequence of positions ranges to get (as in get(long))
      Returns:
      A new RowSet, containing the row keys from this RowSet at the row positions in posRowSequence
    • get

      long get(long rowPosition)
      Returns the row key at the given row position.
      Parameters:
      rowPosition - A row position in this RowSet between 0 and size() - 1.
      Returns:
      The row key at the supplied row position
    • getKeysForPositions

      void getKeysForPositions(PrimitiveIterator.OfLong inputPositions, LongConsumer outputKeys)
      Returns the sequence of (increasing) keys corresponding to the positions provided as input.
      Parameters:
      inputPositions - an iterator providing row positions in increasing order.
      outputKeys - a consumer of corresponding keys for the positions provided as input.
    • find

      long find(long key)
      Returns the position in [0..(size-1)] where the key is found. If not found, then return (-(position it would be) - 1), a la Array.binarySearch.
      Parameters:
      key - the key to search for
      Returns:
      a position from [0..(size-1)] if the key was found. If the key was not found, then (-position - 1) as in Array.binarySearch.
    • iterator

      @NotNull @NotNull RowSet.Iterator iterator()
    • searchIterator

      RowSet.SearchIterator searchIterator()
    • reverseIterator

      RowSet.SearchIterator reverseIterator()
    • rangeIterator

      RowSet.RangeIterator rangeIterator()
    • containsRange

      boolean containsRange(long start, long end)
      Queries whether this RowSet contains every element in the range provided.
      Parameters:
      start - Start of the range, inclusive.
      end - End of the range, inclusive.
      Returns:
      true if this RowSet contains every element x in start <= x <= end.
    • validate

      void validate(String failMsg)
    • validate

      default void validate()
    • isWritable

      default boolean isWritable()
      Returns:
      Whether this RowSet is actually writable
    • writableCast

      default WritableRowSet writableCast()

      Cast this RowSet reference to a WritableRowSet.

      Returns:
      this cast to a WritableRowSet
      Throws:
      ClassCastException - If this is not a WritableRowSet
    • isTracking

      default boolean isTracking()
      Returns:
      Whether this RowSet is actually tracking
    • trackingCast

      default TrackingRowSet trackingCast()

      Cast this RowSet reference to a TrackingRowSet.

      Returns:
      this cast to a TrackingRowSet
      Throws:
      ClassCastException - If this is not a TrackingRowSet