Class RowSetShiftData.SmartCoalescingBuilder

java.lang.Object
io.deephaven.engine.rowset.RowSetShiftData.SmartCoalescingBuilder
All Implemented Interfaces:
SafeCloseable, AutoCloseable
Enclosing class:
RowSetShiftData

public static final class RowSetShiftData.SmartCoalescingBuilder extends Object implements SafeCloseable
Helper utility to build instances of RowSetShiftData with internally consistent data. No other ranges should be added to this builder after RowSetShiftData.Builder.build() is invoked.

Differs from RowSetShiftData.Builder in that it coalesces ranges with the same delta if they have no intervening keys in the pre-shift keys of the input.

The data should be presented to the builder in shift iterator order, meaning the first contiguous run with a given polarity is presented to the builder, then the next run is presented with the opposite polarity. When the polarity is reversed (i.e., the delta is positive); the ranges must be presented in reverse (descending) order within the run. When the polarity is not reversed (i.e., the delta is negative); the ranges must be presented in ascending order.

  • Constructor Details

    • SmartCoalescingBuilder

      public SmartCoalescingBuilder(@NotNull @NotNull RowSet preShiftKeys)
      Make a builder that tries to coalesce non-adjacent ranges with the same delta if there are no intervening keys in the pre-shift ordered keys.
      Parameters:
      preShiftKeys - The pre-shift ordered keys for the space being shifted.
  • Method Details

    • nonempty

      public boolean nonempty()
      Returns:
      true iff there is at least one shift appended to this builder
    • shiftRange

      public void shiftRange(long beginRange, long endRange, long shiftDelta)
      Shift a range of keys. The shift must be consistent with previously added shifts.
      Parameters:
      beginRange - first key to shift (inclusive)
      endRange - last key to shift (inclusive)
      shiftDelta - offset to shift by; may be negative
    • build

      public RowSetShiftData build()
      Make final modifications to the RowSetShiftData and return it. Invoke close() to minimize the lifetime of the pre-shift RowSequence.Iterator.
      Returns:
      The built RowSetShiftData
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface SafeCloseable