Class IndexShiftData.SmartCoalescingBuilder

java.lang.Object
com.illumon.iris.db.v2.utils.IndexShiftData.SmartCoalescingBuilder
All Implemented Interfaces:
SafeCloseable, AutoCloseable
Enclosing class:
IndexShiftData

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

Differs from IndexShiftData.Builder in that it coalesces ranges with the same delta if they have no intervening keys in the pre-shift keys of the input, e.g. a Table.

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 ReadOnlyIndex 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 IndexShiftData build()
      Make final modifications to the IndexShiftData and return it. Invoke close() to minimize the lifetime of the pre-shift OrderedKeys.Iterator.
      Returns:
      The built IndexShiftData
    • close

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