Class NaturalJoinModifiedSlotTracker

java.lang.Object
io.deephaven.engine.table.impl.NaturalJoinModifiedSlotTracker

public class NaturalJoinModifiedSlotTracker extends Object
A tracker for modified join hash table slots. After adding an entry, you get back a cookie, which must be passed in on future modification operations for that slot. To process the entries after modifications are complete, call forAllModifiedSlots(ModifiedSlotConsumer).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte
    the slot has accumulated left row keys to add (in slotLeftRowSetBuilders)
    static final byte
    the slot has accumulated left row keys to remove (in slotLeftRowSetBuilders)
    static final byte
    the slot has accumulated post-shift left row keys of one shift range (in slotLeftRowSetBuilders)
    static final int
     
    static final byte
     
    static final byte
     
    static final byte
     
    static final byte
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    addLeftAddition(long cookie, int slot, long addedRowKey, long rightValue)
    Accumulate a left row key that must be added to slot.
    long
    addLeftRemoval(long cookie, int slot, long removedRowKey, long rightValue)
    Accumulate a left row key that must be removed from slot.
    long
    addLeftShift(long cookie, int slot, long shiftedRowKey, long rightValue)
    Accumulate the post-shift row key of a left row of slot that one shift range moves.
    long
    addMain(long cookie, int slot, long originalRightValue, byte flags)
    Add a slot in the main table.
    long
    addMainRightAdd(long cookie, int slot, long originalRightValue, long addedRightRowKey, byte flags)
    Record a right row arriving at addedRightRowKey in slot.
    void
    For each slot that has accumulated left additions, build the added-key row set and pass it to the consumer, then discard the slot's builder and clear its FLAG_LEFT_ADD flag (so the final forAllModifiedSlots(ModifiedSlotConsumer) pass does not re-process it).
    void
    For each slot that has accumulated left removals, build the removed-key row set and pass it to the consumer, then discard the slot's builder and clear its FLAG_LEFT_REMOVE flag (so a subsequent removal pass and the final forAllModifiedSlots(ModifiedSlotConsumer) pass do not re-process it).
    void
    For each slot that has accumulated left shifts, build the post-shift row set of the shifted keys and pass it to the consumer, then discard the slot's builder and clear its FLAG_LEFT_SHIFT flag (so a subsequent shift range and the final forAllModifiedSlots(ModifiedSlotConsumer) pass do not re-process it).
    void
    moveTableLocation(long cookie, int oldTableLocation, int newTableLocation)
    Move a main table location.
    void
    removeEntry(long cookie)
    Discard the entry for a slot that has been tombstoned.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FLAG_MASK

      public static final int FLAG_MASK
      See Also:
    • FLAG_RIGHT_SHIFT

      public static final byte FLAG_RIGHT_SHIFT
      See Also:
    • FLAG_RIGHT_MODIFY_PROBE

      public static final byte FLAG_RIGHT_MODIFY_PROBE
      See Also:
    • FLAG_RIGHT_CHANGE

      public static final byte FLAG_RIGHT_CHANGE
      See Also:
    • FLAG_RIGHT_ADD

      public static final byte FLAG_RIGHT_ADD
      See Also:
    • FLAG_LEFT_REMOVE

      public static final byte FLAG_LEFT_REMOVE
      the slot has accumulated left row keys to remove (in slotLeftRowSetBuilders)
      See Also:
    • FLAG_LEFT_ADD

      public static final byte FLAG_LEFT_ADD
      the slot has accumulated left row keys to add (in slotLeftRowSetBuilders)
      See Also:
    • FLAG_LEFT_SHIFT

      public static final byte FLAG_LEFT_SHIFT
      the slot has accumulated post-shift left row keys of one shift range (in slotLeftRowSetBuilders)
      See Also:
  • Constructor Details

    • NaturalJoinModifiedSlotTracker

      public NaturalJoinModifiedSlotTracker()
  • Method Details

    • addMain

      public long addMain(long cookie, int slot, long originalRightValue, byte flags)
      Add a slot in the main table.
      Parameters:
      slot - the slot to add.
      originalRightValue - the slot's right state before this modification (a right row key, a duplicate location token, or one of the no-right-row markers); recorded only if this call creates the entry
      flags - the flags to or into our state
      Returns:
      the cookie for future access
    • addMainRightAdd

      public long addMainRightAdd(long cookie, int slot, long originalRightValue, long addedRightRowKey, byte flags)
      Record a right row arriving at addedRightRowKey in slot. Beyond flags, this marks FLAG_RIGHT_ADD when the arriving row takes the row key this slot's entry recorded as its original right row: the left rows' redirection then names a different row than it did before, even though the row key it holds is unchanged. That happens when the previously selected right row shifts away from its key within the same cycle and a new right row for the same join key is added at the vacated key.
      Parameters:
      cookie - the slot's existing cookie (or an invalid cookie if this slot has not been tracked yet)
      slot - the hash slot (encoding main/alternate via the insert mask)
      originalRightValue - the slot's right state before this addition
      addedRightRowKey - the row key of the arriving right row
      flags - the flags to or into our state
      Returns:
      the cookie for future access
    • addLeftRemoval

      public long addLeftRemoval(long cookie, int slot, long removedRowKey, long rightValue)
      Accumulate a left row key that must be removed from slot. The removal is not performed here; the key is appended to the slot's sequential builder and the FLAG_LEFT_REMOVE flag is set. The caller performs the removals in bulk later via forAllLeftRemovals(LeftRowSetConsumer).
      Parameters:
      cookie - the slot's existing cookie (or an invalid cookie if this slot has not been tracked yet)
      slot - the hash slot (encoding main/alternate via the insert mask)
      removedRowKey - the left row key to remove from the slot
      rightValue - the slot's current right state, used as the original right value if we must allocate an entry
      Returns:
      the cookie for future access
    • addLeftAddition

      public long addLeftAddition(long cookie, int slot, long addedRowKey, long rightValue)
      Accumulate a left row key that must be added to slot. The insertion is not performed here; the key is appended to the slot's sequential builder and the FLAG_LEFT_ADD flag is set. The caller performs the insertions in bulk later via forAllLeftAdditions(boolean, LeftRowSetConsumer).
      Parameters:
      cookie - the slot's existing cookie (or an invalid cookie if this slot has not been tracked yet)
      slot - the hash slot (encoding main/alternate via the insert mask)
      addedRowKey - the left row key to add to the slot
      rightValue - the slot's current right state, used as the original right value if we must allocate an entry
      Returns:
      the cookie for future access
    • addLeftShift

      public long addLeftShift(long cookie, int slot, long shiftedRowKey, long rightValue)
      Accumulate the post-shift row key of a left row of slot that one shift range moves. The slot's left row set is not touched here; the key is appended to the slot's sequential builder and the FLAG_LEFT_SHIFT flag is set. The caller performs the shift of each slot's rows in bulk via forAllLeftShifts(LeftRowSetConsumer) once the range's rows have all been probed.
      Parameters:
      cookie - the slot's existing cookie (or an invalid cookie if this slot has not been tracked yet)
      slot - the hash slot (encoding main/alternate via the insert mask)
      shiftedRowKey - the post-shift row key of the left row
      rightValue - the slot's current right state, used as the original right value if we must allocate an entry
      Returns:
      the cookie for future access
    • removeEntry

      public void removeEntry(long cookie)
      Discard the entry for a slot that has been tombstoned. The slot no longer describes the key the entry was recorded for, so the entry must not be applied to whatever key later reuses the slot.
      Parameters:
      cookie - the slot's cookie; an invalid cookie means the slot has no entry this cycle
    • moveTableLocation

      public void moveTableLocation(long cookie, int oldTableLocation, int newTableLocation)
      Move a main table location.
      Parameters:
      oldTableLocation - the old hash slot
      newTableLocation - the new hash slot
    • forAllLeftRemovals

      public void forAllLeftRemovals(NaturalJoinModifiedSlotTracker.LeftRowSetConsumer consumer)
      For each slot that has accumulated left removals, build the removed-key row set and pass it to the consumer, then discard the slot's builder and clear its FLAG_LEFT_REMOVE flag (so a subsequent removal pass and the final forAllModifiedSlots(ModifiedSlotConsumer) pass do not re-process it). The row set handed to the consumer is owned by this method and closed after the consumer returns.
      Parameters:
      consumer - the consumer of each slot's removed left row keys
    • forAllLeftShifts

      public void forAllLeftShifts(NaturalJoinModifiedSlotTracker.LeftRowSetConsumer consumer)
      For each slot that has accumulated left shifts, build the post-shift row set of the shifted keys and pass it to the consumer, then discard the slot's builder and clear its FLAG_LEFT_SHIFT flag (so a subsequent shift range and the final forAllModifiedSlots(ModifiedSlotConsumer) pass do not re-process it). The row set handed to the consumer is owned by this method and closed after the consumer returns.
      Parameters:
      consumer - the consumer of each slot's shifted left row keys
    • forAllLeftAdditions

      public void forAllLeftAdditions(boolean addedToTable, NaturalJoinModifiedSlotTracker.LeftRowSetConsumer consumer)
      For each slot that has accumulated left additions, build the added-key row set and pass it to the consumer, then discard the slot's builder and clear its FLAG_LEFT_ADD flag (so the final forAllModifiedSlots(ModifiedSlotConsumer) pass does not re-process it). The row set handed to the consumer is owned by this method and closed after the consumer returns.
      Parameters:
      addedToTable - whether the accumulated keys are rows added to the left table this cycle, in which case they are counted for NaturalJoinModifiedSlotTracker.ModifiedSlotConsumer.accept(int, long, byte, long)
      consumer - the consumer of each slot's added left row keys