private Set<W> windowsThatAreOpen(Collection<W> windows) { Set<W> result = new HashSet<>(); for (W window : windows) { ReduceFn<K, InputT, OutputT, W>.Context directContext = contextFactory.base(window, StateStyle.DIRECT); if (!triggerRunner.isClosed(directContext.state())) { result.add(window); } } return result; }
public ReduceFn<K, InputT, OutputT, W>.OnTriggerContext forTrigger( W window, PaneInfo pane, StateStyle style, OnTriggerCallbacks<OutputT> callbacks) { return new OnTriggerContextImpl(stateAccessor(window, style), pane, callbacks); }
private StateAccessorImpl<K, W> stateAccessor(W window, StateStyle style) { return new StateAccessorImpl<>( activeWindows, windowingStrategy.getWindowFn().windowCoder(), stateInternals, stateContextFromComponents(options, sideInputReader, window), style); }
contextFactory.forPremerge(window); reduceFn.onMerge(premergeContext); watermarkHold.onMerge(premergeContext);
new ReduceFnContextFactory<>( key, reduceFn,
contextFactory.forTrigger( directContext.window(), pane,
@VisibleForTesting boolean isFinished(W window) { return triggerRunner.isClosed(contextFactory.base(window, StateStyle.DIRECT).state()); }
public ReduceFn<K, InputT, OutputT, W>.ProcessValueContext forValue( W window, InputT value, Instant timestamp, StateStyle style) { return new ProcessValueContextImpl(stateAccessor(window, style), value, timestamp); }
private void prefetchWindowsForValues(Collection<W> windows) { // Prefetch in each of the windows if we're going to need to process triggers for (W window : windows) { ReduceFn<K, InputT, OutputT, W>.Context directContext = contextFactory.base(window, StateStyle.DIRECT); triggerRunner.prefetchForValue(window, directContext.state()); } }
public ReduceFn<K, InputT, OutputT, W>.Context base(W window, StateStyle style) { return new ContextImpl(stateAccessor(window, style)); }
private Collection<W> windowsThatShouldFire(Set<W> windows) throws Exception { Collection<W> result = new ArrayList<>(); // Filter out timers that didn't trigger. for (W window : windows) { ReduceFn<K, InputT, OutputT, W>.Context directContext = contextFactory.base(window, StateStyle.DIRECT); if (triggerRunner.shouldFire( directContext.window(), directContext.timers(), directContext.state())) { result.add(window); } } return result; }