@Override public Iterable<IntWindow> assignWindowsToElement(WindowedElement<?, Integer> input) { return Collections.singleton(new IntWindow(input.getElement() / 4)); }
@Override @SuppressWarnings("unchecked") public Iterable<W> assignWindowsToElement(WindowedElement<?, T> input) { return Collections.singleton((W) input.getWindow()); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { long stamp = el.getTimestamp(); long start = stamp - (stamp + durationMillis) % durationMillis; long end = start + durationMillis; return singleton(new TimeInterval(start, end)); }
@SuppressWarnings("unchecked") public void process(WindowedElement<WID, Pair<KEY, I>> elem) { // ~ make sure we have the key updateKey(elem); // ~ advance our clock clock.updateStamp(elem.getTimestamp(), this::onTimerCallback); // ~ get the target window WID window = elem.getWindow(); // ~ merge the new window into existing ones if necessary if (windowing instanceof MergingWindowing) { window = mergeWindows(window); } // ~ add the value to the target window state { State state = getStateForUpdate(window); state.add(elem.getElement().getSecond()); } // ~ process trigger#onElement { ElementTriggerContext trgCtx = new ElementTriggerContext(window); Trigger.TriggerResult windowTr = trigger.onElement(elem.getTimestamp(), window, trgCtx); processTriggerResult(window, trgCtx, windowTr); } }
@SuppressWarnings("unchecked") public void process(WindowedElement<WID, Pair<KEY, I>> elem) { // ~ make sure we have the key updateKey(elem); // ~ advance our clock clock.updateStamp(elem.getTimestamp(), this::onTimerCallback); // ~ get the target window WID window = elem.getWindow(); // ~ merge the new window into existing ones if necessary if (windowing instanceof MergingWindowing) { window = mergeWindows(window); } // ~ add the value to the target window state { State state = getStateForUpdate(window); state.add(elem.getElement().getSecond()); } // ~ process trigger#onElement { ElementTriggerContext trgCtx = new ElementTriggerContext(window); Trigger.TriggerResult windowTr = trigger.onElement(elem.getTimestamp(), window, trgCtx); processTriggerResult(window, trgCtx, windowTr); } }
@Override public Iterable<IntWindow> assignWindowsToElement(WindowedElement<?, Integer> input) { return Collections.singleton(new IntWindow(input.getElement() / 4)); }
@Override @SuppressWarnings("unchecked") public Iterable<W> assignWindowsToElement(WindowedElement<?, T> input) { return Collections.singleton((W) input.getWindow()); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { long stamp = el.getTimestamp(); TimeInterval ret = new TimeInterval(stamp, stamp + gapDurationMillis); return Collections.singleton(ret); }
private void updateKey(WindowedElement<WID, Pair<KEY, I>> elem) { if (key == null) { key = elem.getElement().getFirst(); } else { // ~ validate we really do process elements of a single key only Preconditions.checkState(key.equals(elem.getElement().getFirst())); } }
@SuppressWarnings("unchecked") @Override public Iterable<W> assignWindowsToElement(WindowedElement<?, T> input) { return Collections.singleton((W) input.getWindow()); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { long stamp = el.getTimestamp(); TimeInterval ret = new TimeInterval(stamp, stamp + gapDurationMillis); return Collections.singleton(ret); }
private void updateKey(WindowedElement<WID, Pair<KEY, I>> elem) { if (key == null) { key = elem.getElement().getFirst(); } else { // ~ validate we really do process elements of a single key only Preconditions.checkState(key.equals(elem.getElement().getFirst())); } }
@SuppressWarnings("unchecked") @Override public Iterable<W> assignWindowsToElement(WindowedElement<?, T> input) { return Collections.singleton((W) input.getWindow()); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { long stamp = el.getTimestamp(); long start = stamp - (stamp + durationMillis) % durationMillis; long end = start + durationMillis; return singleton(new TimeInterval(start, end)); }
@Override public Iterable<IntWindow> assignWindowsToElement( WindowedElement<?, Either<Integer, Long>> input) { int element; Either<Integer, Long> unwrapped = input.getElement(); if (unwrapped.isLeft()) { element = unwrapped.left(); } else { element = (int) (long) unwrapped.right(); } final int label = element % 2 == 0 ? 0 : element; return Collections.singleton(new IntWindow(label)); }
@Override @SuppressWarnings("unchecked") public Iterable<WID> assignWindowsToElement(WindowedElement<?, T> el) { return Collections.singleton((WID) el.getWindow()); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { return new SlidingWindowSet(el.getTimestamp(), duration, slide); }
@Override public Iterable<IntWindow> assignWindowsToElement( WindowedElement<?, Either<Integer, Long>> input) { int element; Either<Integer, Long> unwrapped = input.getElement(); if (unwrapped.isLeft()) { element = unwrapped.left(); } else { element = (int) (long) unwrapped.right(); } final int label = element % 2 == 0 ? 0 : element; return Collections.singleton(new IntWindow(label)); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { return new SlidingWindowSet(el.getTimestamp(), duration, slide); }
@Override public Iterable<SizedCountWindow> assignWindowsToElement(WindowedElement<?, T> input) { int sz = sizeFn.apply(input.getElement()); return Sets.newHashSet(new SizedCountWindow(sz), new SizedCountWindow(2 * sz)); }