Class OperationSnapshotControlEx
- All Implemented Interfaces:
ConstructSnapshot.SnapshotCompletedConsistently,ConstructSnapshot.SnapshotConsistent,ConstructSnapshot.SnapshotControl,ConstructSnapshot.UsePreviousValues
OperationSnapshotControl that considers "extra" dependencies
in addition to the source BaseTable when determining whether to use previous values during initialization or
evaluating success. This is useful anytime an operation needs to listen to and snapshot one data source while also
snapshotting others.
The decision is made over the source and every extra together. Previous values are used only when none of them has been satisfied on the step. If some are satisfied and others are not, the control waits for the rest and then uses current values; once all are satisfied it uses current values without waiting. A static source cannot be unsatisfied, so it does not count.
For the consistency check afterwards, extras are treated as notification oblivious by default: their notifications do not invalidate a snapshot, because their previous values remain stable for the whole cycle and a snapshot using previous values reads them consistently no matter when they tick. That is the correct treatment for the usual extras, which are tables or table-backed structures such as data index tables.
An extra that also implements NotificationAwareDependency is the exception: it keeps no previous version of
the state it guards, so a snapshot that used previous values while that extra changed its state on the same step must
be retried. Such extras are detected automatically from those passed to the constructor, so callers need do nothing
beyond passing them as dependencies.
On an update-processing thread a snapshot never uses previous values and cannot wait, so any unsatisfied dependency
is an IllegalStateException: the operation must be ordered after that dependency by the caller.
-
Constructor Summary
ConstructorsConstructorDescriptionOperationSnapshotControlEx(@NotNull BaseTable<?> sourceTable, NotificationQueue.Dependency... extras) -
Method Summary
Modifier and TypeMethodDescriptionbooleansnapshotCompletedConsistently(long afterClockValue, boolean usedPreviousValues) Ends a snapshot.booleansnapshotConsistent(long currentClockValue, boolean usingPreviousValues) Determine (from within a snapshot function) if the snapshot appears to still be consistent.usePreviousValues(long beforeClockValue) Starts a snapshot.Methods inherited from class io.deephaven.engine.table.impl.OperationSnapshotControl
getUpdateGraph, isInInitialNotificationWindow, setListenerAndResult
-
Constructor Details
-
OperationSnapshotControlEx
public OperationSnapshotControlEx(@NotNull @NotNull BaseTable<?> sourceTable, @NotNull NotificationQueue.Dependency... extras)
-
-
Method Details
-
usePreviousValues
Description copied from class:OperationSnapshotControlStarts a snapshot. Overriding methods must callOperationSnapshotControl.clearListenerAndResult()in order to discard any listener and result left behind by a previous attempt.- Specified by:
usePreviousValuesin interfaceConstructSnapshot.UsePreviousValues- Overrides:
usePreviousValuesin classOperationSnapshotControl- 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.SnapshotConsistentDetermine (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. SeeConstructSnapshot.clockConsistent(long, long, boolean).- Specified by:
snapshotConsistentin interfaceConstructSnapshot.SnapshotConsistent- Overrides:
snapshotConsistentin classOperationSnapshotControl- Parameters:
currentClockValue- The current clock valueusingPreviousValues- 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
public boolean snapshotCompletedConsistently(long afterClockValue, boolean usedPreviousValues) Description copied from class:OperationSnapshotControlEnds a snapshot. Overriding methods must callsuperin order to ensure that the result's last notification step is properly set.- Specified by:
snapshotCompletedConsistentlyin interfaceConstructSnapshot.SnapshotCompletedConsistently- Specified by:
snapshotCompletedConsistentlyin interfaceConstructSnapshot.SnapshotControl- Overrides:
snapshotCompletedConsistentlyin classOperationSnapshotControl- Parameters:
afterClockValue- Thelogical clockcycle we are ending a snapshot onusedPreviousValues- Whether we used previous values during the snapshot- Returns:
- true if the snapshot was successful, false if we should try again.
-