Class OperationSnapshotControl

java.lang.Object
io.deephaven.engine.table.impl.OperationSnapshotControl
All Implemented Interfaces:
ConstructSnapshot.SnapshotCompletedConsistently, ConstructSnapshot.SnapshotConsistent, ConstructSnapshot.SnapshotControl, ConstructSnapshot.UsePreviousValues
Direct Known Subclasses:
OperationSnapshotControlEx

public class OperationSnapshotControl extends Object implements ConstructSnapshot.SnapshotControl
A simple implementation of ConstructSnapshot.SnapshotControl that uses the last notification step of the source table to determine whether to use previous values during initialization and to evaluate success.
  • Constructor Details

    • OperationSnapshotControl

      public OperationSnapshotControl(BaseTable<?> sourceTable)
  • Method Details

    • getUpdateGraph

      public UpdateGraph getUpdateGraph()
      Specified by:
      getUpdateGraph in interface ConstructSnapshot.SnapshotControl
      Returns:
      The UpdateGraph that applies for this snapshot; null for snapshots of static data, which can skip all consistency-related considerations
    • usePreviousValues

      public Boolean usePreviousValues(long beforeClockValue)
      Starts a snapshot.
      Specified by:
      usePreviousValues in interface ConstructSnapshot.UsePreviousValues
      Parameters:
      beforeClockValue - the logical clock value we are starting a snapshot on
      Returns:
      true if we should use previous values, false if we should use current values.
    • snapshotConsistent

      public boolean snapshotConsistent(long currentClockValue, boolean usingPreviousValues)
      Description copied from interface: ConstructSnapshot.SnapshotConsistent

      Determine (from within a snapshot function) if the snapshot appears to still be consistent.

      This should be no more restrictive than the associated ConstructSnapshot.SnapshotCompletedConsistently.

      Can assume as a precondition that the clock step has not been observed to change since the last time the associated ConstructSnapshot.UsePreviousValues.usePreviousValues(long) was invoked, and that the clock state has not been observed to change if previous values were used. See ConstructSnapshot.clockConsistent(long, long, boolean).

      Specified by:
      snapshotConsistent in interface ConstructSnapshot.SnapshotConsistent
      Parameters:
      currentClockValue - The current clock value
      usingPreviousValues - Whether the snapshot function is using previous values
      Returns:
      True if we can no longer expect that the snapshot function's result will be consistent
    • snapshotCompletedConsistently

      @OverridingMethodsMustInvokeSuper public boolean snapshotCompletedConsistently(long afterClockValue, boolean usedPreviousValues)
      Ends a snapshot. Overriding methods must call super in order to ensure that the result's last notification step is properly set.
      Specified by:
      snapshotCompletedConsistently in interface ConstructSnapshot.SnapshotCompletedConsistently
      Specified by:
      snapshotCompletedConsistently in interface ConstructSnapshot.SnapshotControl
      Parameters:
      afterClockValue - The logical clock cycle we are ending a snapshot on
      usedPreviousValues - Whether we used previous values during the snapshot
      Returns:
      true if the snapshot was successful, false if we should try again.
      Throws:
      IllegalStateException - If the snapshot was successful (consistent), but the snapshot function failed to set the eventual listener or eventual result
    • isInInitialNotificationWindow

      protected boolean isInInitialNotificationWindow()
      Returns:
      Whether we are in the initial notification window and can continue with the snapshot
    • setListenerAndResult

      public void setListenerAndResult(TableUpdateListener listener, @NotNull @NotNull NotificationStepReceiver resultTable)
      Set the listener that will eventually become the listener, if we have a successful snapshot.
      Parameters:
      listener - The listener that we will eventually forward all updates to
      resultTable - The table that will result from this operation