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
Nested ClassesModifier and TypeClassDescriptionstatic classHelper utility to build instances ofRowSetShiftDatawith internally consistent data.static interfacestatic interfacestatic final classHelper utility to build instances ofRowSetShiftDatawith internally consistent data. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RowSetShiftDataImmutable, re-usableRowSetShiftDatafor an empty set of shifts. -
Method Summary
Modifier and TypeMethodDescriptionlongapply(long keyToShift) Apply all shifts tokeyToShift.voidapply(RowKeyRangeShiftCallback shiftCallback) Apply all shifts in a memmove-semantics-safe ordering through the providedshiftCallback.apply(WritableRowSet rowSet) Apply all shifts torowSet.static booleanapplyShift(@NotNull WritableRowSet rowSet, long beginRange, long endRange, long shiftDelta) Apply a shift to the provided rowSet.booleanempty()Queries whether this RowSetShiftData is empty (i.e.booleanextractParallelShiftedRowsFromPostShiftRowSet(RowSet postShiftRowSet) This method creates two parallel RowSet structures that contain postShiftRowSet keys affected by shifts.voidforAllInRowSet(RowSet filterRowSet, RowSetShiftData.SingleElementShiftCallback callback) longgetBeginRange(int idx) Get the inclusive begin offset of theidxth shift.longThe number of keys affected by shift commands.longgetEffectiveSizeClamped(long clamp) The number of keys affected by shift commands.longgetEndRange(int idx) Get the inclusive end offset of theidxth shift.longgetShiftDelta(int idx) Get the absolute shift of theidxth shift.Intersects this RowSetShiftData against the provided RowSet.booleannonempty()Queries whether this RowSetShiftData is non-empty (i.e.intsize()The number of shifts embedded in the payload.toString()voidunapply(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 booleanunapplyShift(@NotNull WritableRowSet rowSet, long beginRange, long endRange, long shiftDelta) Unapply a shift to the provided rowSet.voidvalidate()Verify invariants of internal data structures hold.
-
Field Details
-
EMPTY
Immutable, re-usableRowSetShiftDatafor 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 theidxth shift.- Parameters:
idx- which pair to get offset for- Returns:
- the offset
-
getEndRange
public long getEndRange(int idx) Get the inclusive end offset of theidxth shift.- Parameters:
idx- which pair to get offset for- Returns:
- the offset
-
getShiftDelta
public long getShiftDelta(int idx) Get the absolute shift of theidxth 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:
appendin 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. MovesrowSetfrom pre-shift keyspace to post-shift keyspace.- Parameters:
rowSet- TheWritableRowSetto 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. MovesrowSetfrom post-shift keyspace to pre-shift keyspace.- Parameters:
rowSet- TheWritableRowSetto shift- Returns:
rowSet
-
unapply
Unapply all shifts torowSet. MovesrowSetfrom post-shift keyspace to pre-shift keyspace.- Parameters:
rowSet- TheWritableRowSetto 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.
-