Package io.deephaven.engine.rowset
Class RowSetShiftData
java.lang.Object
io.deephaven.engine.rowset.RowSetShiftData
- All Implemented Interfaces:
LogOutputAppendable
,Serializable
A set of sorted shifts. To apply shifts without losing data, use
apply(RowKeyRangeShiftCallback)
. The callback will be invoked with shifts in an order that
will preserve data when applied immediately using memmove semantics. Internally the shifts are ordered by rangeStart.
The RowSetShiftData.Builder
will verify that no two ranges overlap before or after shifting and assert that
the constructed RowSetShiftData
will be valid.- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Helper utility to build instances ofRowSetShiftData
with internally consistent data.static interface
static interface
static final class
Helper utility to build instances ofRowSetShiftData
with internally consistent data. -
Field Summary
Modifier and TypeFieldDescriptionstatic final RowSetShiftData
Immutable, re-usableRowSetShiftData
for an empty set of shifts. -
Method Summary
Modifier and TypeMethodDescriptionlong
apply
(long keyToShift) Apply all shifts tokeyToShift
.void
apply
(RowKeyRangeShiftCallback shiftCallback) Apply all shifts in a memmove-semantics-safe ordering through the providedshiftCallback
.apply
(WritableRowSet rowSet) Apply all shifts torowSet
.static boolean
applyShift
(@NotNull WritableRowSet rowSet, long beginRange, long endRange, long shiftDelta) Apply a shift to the provided rowSet.boolean
empty()
Queries whether this RowSetShiftData is empty (i.e.boolean
extractParallelShiftedRowsFromPostShiftRowSet
(RowSet postShiftRowSet) This method creates two parallel RowSet structures that contain postShiftRowSet keys affected by shifts.void
forAllInRowSet
(RowSet filterRowSet, RowSetShiftData.SingleElementShiftCallback callback) long
getBeginRange
(int idx) Get the inclusive begin offset of theidx
th shift.long
The number of keys affected by shift commands.long
getEffectiveSizeClamped
(long clamp) The number of keys affected by shift commands.long
getEndRange
(int idx) Get the inclusive end offset of theidx
th shift.long
getShiftDelta
(int idx) Get the absolute shift of theidx
th shift.Intersects this RowSetShiftData against the provided RowSet.boolean
nonempty()
Queries whether this RowSetShiftData is non-empty (i.e.int
size()
The number of shifts embedded in the payload.toString()
void
unapply
(RowKeyRangeShiftCallback shiftCallback) Apply all shifts in reverse in a memmove-semantics-safe ordering through the providedshiftCallback
.unapply
(WritableRowSet rowSet) Unapply all shifts torowSet
.unapply
(WritableRowSet rowSet, long offset) Unapply all shifts torowSet
.static boolean
unapplyShift
(@NotNull WritableRowSet rowSet, long beginRange, long endRange, long shiftDelta) Unapply a shift to the provided rowSet.void
validate()
Verify invariants of internal data structures hold.
-
Field Details
-
EMPTY
Immutable, re-usableRowSetShiftData
for an empty set of shifts.
-
-
Method Details
-
size
public int size()The number of shifts embedded in the payload.- Returns:
- the number of shifts
-
getEffectiveSize
public long getEffectiveSize()The number of keys affected by shift commands.- Returns:
- number of keys affected by shifts
-
getEffectiveSizeClamped
public long getEffectiveSizeClamped(long clamp) The number of keys affected by shift commands.- Parameters:
clamp
- the maximum size to return- Returns:
- number of keys affected by shifts
-
getBeginRange
public long getBeginRange(int idx) Get the inclusive begin offset of theidx
th shift.- Parameters:
idx
- which pair to get offset for- Returns:
- the offset
-
getEndRange
public long getEndRange(int idx) Get the inclusive end offset of theidx
th shift.- Parameters:
idx
- which pair to get offset for- Returns:
- the offset
-
getShiftDelta
public long getShiftDelta(int idx) Get the absolute shift of theidx
th shift.- Parameters:
idx
- which pair to get shift for- Returns:
- the shift
-
validate
public void validate()Verify invariants of internal data structures hold. -
empty
public boolean empty()Queries whether this RowSetShiftData is empty (i.e. has no shifts).- Returns:
- true if the size() of this is zero, false if the size is greater than zero
-
nonempty
public boolean nonempty()Queries whether this RowSetShiftData is non-empty (i.e. has at least one shift).- Returns:
- true if the size() of this TrackingWritableRowSet greater than zero, false if the size is zero
-
toString
-
append
- Specified by:
append
in interfaceLogOutputAppendable
-
append
-
equals
-
apply
Apply all shifts in a memmove-semantics-safe ordering through the providedshiftCallback
.Use this to move from pre-shift keyspace to post-shift keyspace.
- Parameters:
shiftCallback
- the callback that will process all shifts
-
unapply
Apply all shifts in reverse in a memmove-semantics-safe ordering through the providedshiftCallback
.Use this to move from post-shift keyspace to pre-shift keyspace.
- Parameters:
shiftCallback
- the callback that will process all reverse shifts
-
apply
Apply all shifts torowSet
. MovesrowSet
from pre-shift keyspace to post-shift keyspace.- Parameters:
rowSet
- TheWritableRowSet
to shift- Returns:
rowSet
-
apply
public long apply(long keyToShift) Apply all shifts tokeyToShift
. Moves the single row key from pre-shift keyspace to post-shift keyspace.- Parameters:
keyToShift
- The single row key to shift- Returns:
- the key in post-shift space
-
applyShift
public static boolean applyShift(@NotNull @NotNull WritableRowSet rowSet, long beginRange, long endRange, long shiftDelta) Apply a shift to the provided rowSet. Moves rowSet from pre-shift keyspace to post-shift keyspace.- Parameters:
rowSet
- The rowSet to apply the shift tobeginRange
- start of range (inclusive)endRange
- end of range (inclusive)shiftDelta
- amount range has moved by- Returns:
- Whether there was any overlap found to shift
-
unapply
Unapply all shifts torowSet
. MovesrowSet
from post-shift keyspace to pre-shift keyspace.- Parameters:
rowSet
- TheWritableRowSet
to shift- Returns:
rowSet
-
unapply
Unapply all shifts torowSet
. MovesrowSet
from post-shift keyspace to pre-shift keyspace.- Parameters:
rowSet
- TheWritableRowSet
to shiftoffset
- An additional offset to apply to all shifts (such as when applying to a wrapped table)- Returns:
rowSet
-
unapplyShift
public static boolean unapplyShift(@NotNull @NotNull WritableRowSet rowSet, long beginRange, long endRange, long shiftDelta) Unapply a shift to the provided rowSet. Moves rowSet from post-shift keyspace to pre-shift keyspace.- Parameters:
rowSet
- The rowSet to apply the shift tobeginRange
- start of range (inclusive)endRange
- end of range (inclusive)shiftDelta
- amount range has moved by- Returns:
- Whether there was any overlap found to shift
-
forAllInRowSet
public void forAllInRowSet(RowSet filterRowSet, RowSetShiftData.SingleElementShiftCallback callback) -
applyIterator
-
intersect
Intersects this RowSetShiftData against the provided RowSet.- Parameters:
rowSet
- the rowSet to test for intersections (pre-shift keyspace)- Returns:
- a rowSetShiftData containing only non-empty shifts
-
extractParallelShiftedRowsFromPostShiftRowSet
public SafeCloseablePair<RowSet,RowSet> extractParallelShiftedRowsFromPostShiftRowSet(RowSet postShiftRowSet) This method creates two parallel RowSet structures that contain postShiftRowSet keys affected by shifts. The two RowSets have the same size. An element at position k in the first RowSet is the pre-shift key for the same row whose post-shift key is at position k in the second RowSet.- Parameters:
postShiftRowSet
- The RowSet of keys that were shifted in post-shift keyspace. It should not contain rows that did not exist prior to the shift.- Returns:
- A SafeCloseablePair of preShiftedKeys and postShiftedKeys that intersect this RowSetShiftData with postShiftRowSet.
-