@Override public Iterator<Tuple2<KeyedWindow<W, KEY>, VALUE>> call(SparkElement<?, IN> wel) { final Iterable<W> windows = windowing.assignWindowsToElement(wel); return Iterators.transform( windows.iterator(), wid -> { final long stamp = Objects.requireNonNull(wid).maxTimestamp() - 1; return new Tuple2<>( new KeyedWindow<>(wid, stamp, keyExtractor.apply(wel.getElement())), valueExtractor.apply(wel.getElement())); }); } }
@Override @SuppressWarnings("unchecked") public Iterator<Tuple2<KeyedWindow, Object>> call(SparkElement wel) throws Exception { Iterable<Window> windows = windowing.assignWindowsToElement(wel); return Iterators.transform(windows.iterator(), w -> new Tuple2<>( new KeyedWindow<>(w, wel.getTimestamp(), keyExtractor.apply(wel.getElement())), valueExtractor.apply(wel.getElement()))); } }
<W extends Window, T> Iterable<W> assignWindows(Windowing<T, W> windowing, T elem, UnaryFunction<T, Long> eventTimeAssigner) { return windowing.assignWindowsToElement( new Elem<W, T>(null, elem, eventTimeAssigner.apply(elem))); }
if (allowWindowBasedShuffling) { if (windowing != null) { targetWindows = windowing.assignWindowsToElement(datum); } else { targetWindows = Collections.singleton(datum.getWindow());
if (allowWindowBasedShuffling) { if (windowing != null) { targetWindows = windowing.assignWindowsToElement(datum); } else { targetWindows = Collections.singleton(datum.getWindow());
@Override @SuppressWarnings("unchecked") public void flatMap(BatchElement wel, Collector<BatchElement<Window, Pair>> coll) throws Exception { Iterable<Window> assigned = windowing.assignWindowsToElement(wel); for (Window wid : assigned) { Object el = wel.getElement(); coll.collect(new BatchElement( wid, wid.maxTimestamp(), Pair.of(keyExtractor.apply(el), el))); } } }
@Override @SuppressWarnings("unchecked") public Iterator<Tuple2<KeyedWindow, SparkElement>> call(SparkElement se) throws Exception { final Iterable<Window> windows = windowing.assignWindowsToElement(new SparkElement( se.getWindow(), se.getTimestamp(), left ? Either.left(se.getElement()) : Either.right(se.getElement()))); return Iterators.transform(windows.iterator(), w -> new Tuple2<>( new KeyedWindow<>(w, se.getTimestamp(), keyExtractor.apply(se.getElement())), new SparkElement(w, se.getTimestamp(), se.getElement()))); }
@Override @SuppressWarnings("unchecked") public KeyedMultiWindowedElement<W, KEY, VALUE> apply(StreamRecord<StreamingElement<?, I>> record) { StreamingElement el = record.getValue(); if (reuse == null) { reuse = new TimestampedElement(); } reuse.setTimestamp(record.getTimestamp()); reuse.setStreamingElement(el); Iterable windows = windowing.assignWindowsToElement(reuse); return new KeyedMultiWindowedElement<>( keyExtractor.apply(el.getElement()), valueExtractor.apply(el.getElement()), windows); }
@SuppressWarnings("unchecked") private void processInputNonMerging(WindowedElement element) { Object item = element.getElement(); Object itemKey = keyExtractor.apply(item); Object itemValue = valueExtractor.apply(item); Iterable<Window> windows = windowing.assignWindowsToElement(element); for (Window window : windows) { ElementTriggerContext pitctx = new ElementTriggerContext(new KeyedWindow(window, itemKey)); State windowState = processing.getWindowStateForUpdate(pitctx.getScope()); windowState.add(itemValue); Trigger.TriggerResult result = trigger.onElement(getCurrentElementTime(), window, pitctx); // ~ handle trigger result handleTriggerResult(result, pitctx); } }
@SuppressWarnings("unchecked") private void processInputNonMerging(WindowedElement element) { Object item = element.getElement(); Object itemKey = keyExtractor.apply(item); Object itemValue = valueExtractor.apply(item); Iterable<Window> windows = windowing.assignWindowsToElement(element); for (Window window : windows) { ElementTriggerContext pitctx = new ElementTriggerContext(new KeyedWindow(window, itemKey)); State windowState = processing.getWindowStateForUpdate(pitctx.getScope()); windowState.add(itemValue); Trigger.TriggerResult result = trigger.onElement(getCurrentElementTime(), window, pitctx); // ~ handle trigger result handleTriggerResult(result, pitctx); } }
Object itemValue = valueExtractor.apply(item); Iterable<Window> windows = windowing.assignWindowsToElement(element); for (Window window : windows) {
Object itemValue = valueExtractor.apply(item); Iterable<Window> windows = windowing.assignWindowsToElement(element); for (Window window : windows) {
input.flatMap((i, c) -> { BatchElement wel = (BatchElement) i; Iterable<Window> assigned = windowing.assignWindowsToElement(wel); for (Window wid : assigned) { Object el = wel.getElement();
input.flatMap((i, c) -> { BatchElement wel = (BatchElement) i; Iterable<Window> assigned = windowing.assignWindowsToElement(wel); for (Window wid : assigned) { Object el = wel.getElement();