public final void injectElements(List<TimestampedValue<InputT>> values) throws Exception { for (TimestampedValue<InputT> value : values) { WindowTracing.trace("TriggerTester.injectElements: {}", value); } Iterable<WindowedValue<InputT>> inputs = values .stream() .map( input -> { try { InputT value = input.getValue(); Instant timestamp = input.getTimestamp(); Collection<W> windows = windowFn.assignWindows( new TestAssignContext<W>( windowFn, value, timestamp, GlobalWindow.INSTANCE)); return WindowedValue.of(value, timestamp, windows, PaneInfo.NO_FIRING); } catch (Exception e) { throw new RuntimeException(e); } }) .collect(Collectors.toList()); ReduceFnRunner<String, InputT, OutputT, W> runner = createRunner(); runner.processElements( new LateDataDroppingDoFnRunner.LateDataFilter(objectStrategy, timerInternals) .filter(KEY, inputs)); // Persist after each bundle. runner.persist(); }
lateDataFilter.filter( "a", ImmutableList.of(
@Override public void processElement(WindowedValue<KeyedWorkItem<K, InputT>> elem) { Iterable<WindowedValue<InputT>> nonLateElements = lateDataFilter.filter(elem.getValue().key(), elem.getValue().elementsIterable()); KeyedWorkItem<K, InputT> keyedWorkItem = KeyedWorkItems.workItem( elem.getValue().key(), elem.getValue().timersIterable(), nonLateElements); doFnRunner.processElement(elem.withValue(keyedWorkItem)); }