public WatermarkHold(TimerInternals timerInternals, WindowingStrategy<?, W> windowingStrategy) { this.timerInternals = timerInternals; this.windowingStrategy = windowingStrategy; this.elementHoldTag = watermarkHoldTagForTimestampCombiner(windowingStrategy.getTimestampCombiner()); }
/** * Add a hold to prevent the output watermark progressing beyond the (possibly adjusted) timestamp * of the element in {@code context}. * * <p>The target time for the aggregated output is shifted by the {@link WindowFn} and combined * with a {@link TimestampCombiner} to determine where the output watermark is held. * * <p>If the target time would be late, then we do not set this hold, but instead add the hold to * allow a final output at GC time. * * <p>See https://s.apache.org/beam-lateness for the full design of how late data and watermarks * interact. */ @Nullable public Instant addHolds(ReduceFn<?, ?, ?, W>.ProcessValueContext context) { Instant hold = addElementHold(context.timestamp(), context); if (hold == null) { hold = addGarbageCollectionHold(context, false /*paneIsEmpty*/); } return hold; }
private void prefetchOnTrigger( final ReduceFn<K, InputT, OutputT, W>.Context directContext, ReduceFn<K, InputT, OutputT, W>.Context renamedContext) { paneInfoTracker.prefetchPaneInfo(directContext); watermarkHold.prefetchExtract(renamedContext); nonEmptyPanes.isEmpty(renamedContext.state()).readLater(); reduceFn.prefetchOnTrigger(directContext.state()); }
contextFactory.forPremerge(window); reduceFn.onMerge(premergeContext); watermarkHold.onMerge(premergeContext); activeWindows.merged(window);
options); this.watermarkHold = new WatermarkHold<>(timerInternals, windowingStrategy); this.triggerRunner = new TriggerStateMachineRunner<>(
watermarkHold.clearHolds(renamedContext); nonEmptyPanes.clearPane(renamedContext.state()); watermarkHold.clearHolds(directContext);
Instant elementHold = shift(timestamp, context.window());
watermarkHold.extractAndRelease(renamedContext, isFinished).read();
watermarkHold.addHolds(renamedContext);
@SafeVarargs public final void assertHasOnlyGlobalAndFinishedSetsAndPaneInfoFor(W... expectedWindows) { assertHasOnlyGlobalAndAllowedTags( ImmutableSet.copyOf(expectedWindows), ImmutableSet.of( TriggerStateMachineRunner.FINISHED_BITS_TAG, PaneInfoTracker.PANE_INFO_TAG, WatermarkHold.watermarkHoldTagForTimestampCombiner( objectStrategy.getTimestampCombiner()), WatermarkHold.EXTRA_HOLD_TAG)); }
addElementHold(BoundedWindow.TIMESTAMP_MIN_VALUE, context); } else { addGarbageCollectionHold(context, false /*paneIsEmpty*/);
@SafeVarargs public final void assertHasOnlyGlobalAndPaneInfoFor(W... expectedWindows) { assertHasOnlyGlobalAndAllowedTags( ImmutableSet.copyOf(expectedWindows), ImmutableSet.of( PaneInfoTracker.PANE_INFO_TAG, WatermarkHold.watermarkHoldTagForTimestampCombiner( objectStrategy.getTimestampCombiner()), WatermarkHold.EXTRA_HOLD_TAG)); }
@SafeVarargs public final void assertHasOnlyGlobalAndStateFor(W... expectedWindows) { assertHasOnlyGlobalAndAllowedTags( ImmutableSet.copyOf(expectedWindows), ImmutableSet.of( ((SystemReduceFn<?, ?, ?, ?, ?>) reduceFn).getBufferTag(), TriggerStateMachineRunner.FINISHED_BITS_TAG, PaneInfoTracker.PANE_INFO_TAG, WatermarkHold.watermarkHoldTagForTimestampCombiner( objectStrategy.getTimestampCombiner()), WatermarkHold.EXTRA_HOLD_TAG)); }