Package io.deephaven.engine.rowset
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 Summary
ConstructorDescriptionSmartCoalescingBuilder
(@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. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Make final modifications to theRowSetShiftData
and return it.void
close()
boolean
nonempty()
void
shiftRange
(long beginRange, long endRange, long shiftDelta) Shift a range of keys.
-
Constructor Details
-
SmartCoalescingBuilder
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
Make final modifications to theRowSetShiftData
and return it. Invokeclose()
to minimize the lifetime of the pre-shiftRowSequence.Iterator
.- Returns:
- The built RowSetShiftData
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSafeCloseable
-