@Override protected TimeInterval computeNext() { TimeInterval window = null; if (start > elementStamp - duration) { window = new TimeInterval(start, start + duration); start -= slide; } else { endOfData(); } return window; } };
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { return new SlidingWindowSet(el.getTimestamp(), duration, slide); }
StateReducer(Windowing windowing, StateFactory<?, ?, State<?, ?>> stateFactory, StateMerger<?, ?, State<?, ?>> stateCombiner, StateContext stateContext, LazyAccumulatorProvider accumulators) { this.windowing = windowing; this.trigger = windowing.getTrigger(); this.stateFactory = stateFactory; this.stateCombiner = stateCombiner; this.stateContext = stateContext; this.accumulators = accumulators; }
@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)); }
@Test public void testWindowAssignment() { Session<?> windowing = Session.of(Duration.ofMillis(10)); Iterable<TimeInterval> windows = windowing.assignWindowsToElement(new TimestampedElement<>(13)); assertEquals(1, Iterables.size(windows)); assertEquals(new TimeInterval(13, 23), Iterables.getOnlyElement(windows)); }
<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))); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { return wrap.assignWindowsToElement(el); }
@Override public Collection<Pair<Collection<TimeInterval>, TimeInterval>> mergeWindows(Collection<TimeInterval> actives) { return wrap.mergeWindows(actives); }
CSession(Duration gap) { wrap = Session.of(gap); }
public static <T> Count<T> of(int count) { return new Count<>(count); }
private TriggerResult registerTimer(TimeInterval window, TriggerContext ctx) { if (ctx.registerTimer(window.maxTimestamp(), window)) { return TriggerResult.NOOP; } // if the time already passed discard the late coming element return TriggerResult.PURGE; } }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { long stamp = el.getTimestamp(); TimeInterval ret = new TimeInterval(stamp, stamp + gapDurationMillis); return Collections.singleton(ret); }
@Override protected TimeInterval computeNext() { TimeInterval window = null; if (start > elementStamp - duration) { window = new TimeInterval(start, start + duration); start -= slide; } else { endOfData(); } return window; } };
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { return new SlidingWindowSet(el.getTimestamp(), duration, slide); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { return wrap.assignWindowsToElement(el); }
@Override public Collection<Pair<Collection<TimeInterval>, TimeInterval>> mergeWindows(Collection<TimeInterval> actives) { return wrap.mergeWindows(actives); }
CSession(Duration gap) { wrap = Session.of(gap); }
public static <T> Count<T> of(int count) { return new Count<>(count); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { long stamp = el.getTimestamp(); TimeInterval ret = new TimeInterval(stamp, stamp + gapDurationMillis); return Collections.singleton(ret); }
@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)); }