Package io.deephaven.engine.rowset
Class RowSetShiftData.Builder
java.lang.Object
io.deephaven.engine.rowset.RowSetShiftData.Builder
- Enclosing class:
- RowSetShiftData
Helper utility to build instances of
RowSetShiftData
with internally consistent data. No other ranges
should be added to this builder after build()
is invoked.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
appendShiftData
(RowSetShiftData innerShiftData, long prevOffset, long prevCardinality, long currOffset, long currCardinality) Use this method to append shifts that propagate from a parent table to a subset of a dependent table.build()
Make final modifications to theRowSetShiftData
and return it.long
getMinimumValidBeginForNextDelta
(long nextShiftDelta) long
Gets the last row key assigned to a shift.void
limitPreviousShiftFor
(long nextShiftBegin, long nextShiftDelta) This method adjusts the previous shift so that the upcoming shift will not be considered overlapping.boolean
nonempty()
void
shiftRange
(long beginRange, long endRange, long shiftDelta) Shift a range of keys.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
nonempty
public boolean nonempty()- Returns:
- true iff there is at least one shift appended to this builder
-
lastShiftEnd
public long lastShiftEnd()Gets the last row key assigned to a shift.- Returns:
- The greatest row key assigned to a shift or -1 if no shifts exist yet.
-
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
-
getMinimumValidBeginForNextDelta
public long getMinimumValidBeginForNextDelta(long nextShiftDelta) -
build
Make final modifications to theRowSetShiftData
and return it.- Returns:
- the built RowSetShiftData
-
appendShiftData
public void appendShiftData(RowSetShiftData innerShiftData, long prevOffset, long prevCardinality, long currOffset, long currCardinality) Use this method to append shifts that propagate from a parent table to a subset of a dependent table. The canonical use-case is merge, where tables are shifted in key-space so that they do not overlap each other. If one of these merged tables has a shift, then it must propagate these shifts to the merged table in the appropriately shifted key space.This method also supports shifting the entire range in addition to propagating upstream shifts. For example, if a table needs more keyspace, then any tables slotted to the right (in a greater keyspace) will need to shift out of the way to free up the keyspace for the table.
This method assumes that 1) the upstream shift data is valid and 2) shifts can be truncated when they extend beyond the table's known range.
- Parameters:
innerShiftData
- the upstream shifts oriented in upstream keyspace [0, innerRange)prevOffset
- the previous offset where this sub-table beganprevCardinality
- the cardinality of the keyspace previously allocated to this tablecurrOffset
- the new offset where this sub-table begins (may be equal to prevOffset)currCardinality
- the cardinality of the keyspace currently allocated to this table
-
limitPreviousShiftFor
public void limitPreviousShiftFor(long nextShiftBegin, long nextShiftDelta) This method adjusts the previous shift so that the upcoming shift will not be considered overlapping. This is useful if the previous shift included empty space for efficiency, but would intersect with our new shift.- Parameters:
nextShiftBegin
- The first real-key that needs to shift in the upcoming shift.nextShiftDelta
- The delta that applies to the upcoming shift.
-