@Override public R get() { ACC accumulator = getInternal(); if (accumulator == null) { return null; } return aggFunction.getResult(accumulator); }
@Override public void apply(W window, Iterable<T> values, Collector<R> out) throws Exception { ACC acc = aggFunction.createAccumulator(); for (T value : values) { acc = aggFunction.add(value, acc); } wrappedFunction.apply(window, Collections.singletonList(aggFunction.getResult(acc)), out); } }
@Override public void process(Byte key, final W window, final InternalWindowContext context, Iterable<T> input, Collector<R> out) throws Exception { ACC acc = aggFunction.createAccumulator(); for (T val : input) { acc = aggFunction.add(val, acc); } this.ctx.window = window; this.ctx.internalContext = context; ProcessAllWindowFunction<V, R, W> wrappedFunction = this.wrappedFunction; wrappedFunction.process(ctx, Collections.singletonList(aggFunction.getResult(acc)), out); }
@Override public void process(K key, final W window, final InternalWindowContext context, Iterable<T> input, Collector<R> out) throws Exception { ACC acc = aggFunction.createAccumulator(); for (T val : input) { acc = aggFunction.add(val, acc); } this.ctx.window = window; this.ctx.internalContext = context; ProcessWindowFunction<V, R, K, W> wrappedFunction = this.wrappedFunction; wrappedFunction.process(key, ctx, Collections.singletonList(aggFunction.getResult(acc)), out); }
@Override public void apply(K key, W window, Iterable<T> values, Collector<R> out) throws Exception { ACC acc = aggFunction.createAccumulator(); for (T val : values) { acc = aggFunction.add(val, acc); } wrappedFunction.apply(key, window, Collections.singletonList(aggFunction.getResult(acc)), out); } }
@SuppressWarnings("unchecked") public static <OUT, ACC, S extends State> S createState( StateDescriptor<S, ACC> stateDescriptor, byte[] serializedState) throws IOException { final ACC accumulator = KvStateSerializer.deserializeValue( serializedState, stateDescriptor.getSerializer()); final OUT state = ((AggregatingStateDescriptor<?, ACC, OUT>) stateDescriptor). getAggregateFunction().getResult(accumulator); return (S) new ImmutableAggregatingState<>(state); } }
@Override String expected(@Nonnull List<ValueWithTs<Integer>> updates, long currentTimestamp) { if (updates.isEmpty()) { return null; } long acc = AGG_FUNC.createAccumulator(); long lastTs = updates.get(0).getTimestamp(); for (ValueWithTs<Integer> update : updates) { if (expired(lastTs, update.getTimestamp())) { acc = AGG_FUNC.createAccumulator(); } acc = AGG_FUNC.add(update.getValue(), acc); lastTs = update.getTimestamp(); } return expired(lastTs, currentTimestamp) ? null : AGG_FUNC.getResult(acc); }
@Override public OUT get() { ACC accumulator = stateTable.get(currentNamespace); return accumulator != null ? aggregateTransformation.aggFunction.getResult(accumulator) : null; }
@Override public OUT get() { ACC accumulator = stateTable.get(currentNamespace); return accumulator != null ? aggregateTransformation.aggFunction.getResult(accumulator) : null; }
@Override public OUT get() { ACC accumulator = keyedState.get(keyContext.getCurrentKey()); return accumulator == null ? null : transformation.aggregateFunction.getResult(accumulator); }
@Override public OUT get() { ACC accumulator = subKeyedValueState.get(operator.getCurrentKey(), namespace); return accumulator == null ? null : aggregateTransformation.aggregateFunction.getResult(accumulator); }
@Override public void process(K key, final W window, final InternalWindowContext context, Iterable<T> input, Collector<R> out) throws Exception { ACC acc = aggFunction.createAccumulator(); for (T val : input) { acc = aggFunction.add(val, acc); } this.ctx.window = window; this.ctx.internalContext = context; ProcessWindowFunction<V, R, K, W> wrappedFunction = this.wrappedFunction; wrappedFunction.process(key, ctx, Collections.singletonList(aggFunction.getResult(acc)), out); }
@Override public void process(K key, final W window, final InternalWindowContext context, Iterable<T> input, Collector<R> out) throws Exception { ACC acc = aggFunction.createAccumulator(); for (T val : input) { acc = aggFunction.add(val, acc); } this.ctx.window = window; this.ctx.internalContext = context; ProcessWindowFunction<V, R, K, W> wrappedFunction = this.wrappedFunction; wrappedFunction.process(key, ctx, Collections.singletonList(aggFunction.getResult(acc)), out); }
@Override public void apply(K key, W window, Iterable<T> values, Collector<R> out) throws Exception { ACC acc = aggFunction.createAccumulator(); for (T val : values) { acc = aggFunction.add(val, acc); } wrappedFunction.apply(key, window, Collections.singletonList(aggFunction.getResult(acc)), out); } }
@Override public void apply(K key, W window, Iterable<T> values, Collector<R> out) throws Exception { final ACC acc = aggFunction.createAccumulator(); for (T val : values) { aggFunction.add(val, acc); } wrappedFunction.apply(key, window, Collections.singletonList(aggFunction.getResult(acc)), out); } }
@Override public void process(Byte key, final W window, final InternalWindowContext context, Iterable<T> input, Collector<R> out) throws Exception { final ACC acc = aggFunction.createAccumulator(); for (T val : input) { aggFunction.add(val, acc); } this.ctx.window = window; this.ctx.internalContext = context; ProcessAllWindowFunction<V, R, W> wrappedFunction = this.wrappedFunction; wrappedFunction.process(ctx, Collections.singletonList(aggFunction.getResult(acc)), out); }
@Override public void apply(W window, Iterable<T> values, Collector<R> out) throws Exception { ACC acc = aggFunction.createAccumulator(); for (T value : values) { acc = aggFunction.add(value, acc); } wrappedFunction.apply(window, Collections.singletonList(aggFunction.getResult(acc)), out); } }
@Override public void process(Byte key, final W window, final InternalWindowContext context, Iterable<T> input, Collector<R> out) throws Exception { ACC acc = aggFunction.createAccumulator(); for (T val : input) { acc = aggFunction.add(val, acc); } this.ctx.window = window; this.ctx.internalContext = context; ProcessAllWindowFunction<V, R, W> wrappedFunction = this.wrappedFunction; wrappedFunction.process(ctx, Collections.singletonList(aggFunction.getResult(acc)), out); }
@Override public void apply(W window, Iterable<T> values, Collector<R> out) throws Exception { final ACC acc = aggFunction.createAccumulator(); for (T value : values) { aggFunction.add(value, acc); } wrappedFunction.apply(window, Collections.singletonList(aggFunction.getResult(acc)), out); } }
@Override public void apply(K key, W window, Iterable<T> values, Collector<R> out) throws Exception { ACC acc = aggFunction.createAccumulator(); for (T val : values) { acc = aggFunction.add(val, acc); } wrappedFunction.apply(key, window, Collections.singletonList(aggFunction.getResult(acc)), out); } }