@Override public Tuple2<K, T> reduce(Tuple2<K, T> value1, Tuple2<K, T> value2) throws Exception { value1.f1 = this.wrappedFunction.reduce(value1.f1, value2.f1); return value1; } }
@Override public void apply(K k, W window, Iterable<T> input, Collector<R> out) throws Exception { T curr = null; for (T val: input) { if (curr == null) { curr = val; } else { curr = reduceFunction.reduce(curr, val); } } wrappedFunction.apply(k, window, Collections.singletonList(curr), out); } }
@Override public void apply(W window, Iterable<T> input, Collector<R> out) throws Exception { T curr = null; for (T val: input) { if (curr == null) { curr = val; } else { curr = reduceFunction.reduce(curr, val); } } wrappedFunction.apply(window, Collections.singletonList(curr), out); } }
@Override public void process(final Context context, Iterable<T> input, Collector<R> out) throws Exception { T curr = null; for (T val: input) { if (curr == null) { curr = val; } else { curr = reduceFunction.reduce(curr, val); } } this.ctx.window = context.window(); this.ctx.context = context; windowFunction.process(ctx, Collections.singletonList(curr), out); }
@Override public void process(K k, final Context context, Iterable<T> input, Collector<R> out) throws Exception { T curr = null; for (T val: input) { if (curr == null) { curr = val; } else { curr = reduceFunction.reduce(curr, val); } } this.ctx.window = context.window(); this.ctx.context = context; windowFunction.process(k, ctx, Collections.singletonList(curr), out); }
@Override public PyObject reduce(PyObject value1, PyObject value2) throws Exception { if (fun == null) { fun = SerializationUtils.deserializeObject(serFun); } try { return AdapterMap.adapt(this.fun.reduce(value1, value2)); } catch (PyException pe) { throw AbstractPythonUDF.createAndLogException(pe, LOG); } } }
@Override public void add(V value) throws Exception { byte[] key = getKeyBytes(); V oldValue = getInternal(key); V newValue = oldValue == null ? value : reduceFunction.reduce(oldValue, value); updateInternal(key, newValue); }
if (entry.hashCode == hash && entry.key.equals(key)) { entry.value = aggregator.reduce(entry.value, value); return entry.value;
@Override public void processElement(StreamRecord<IN> element) throws Exception { IN value = element.getValue(); IN currentValue = values.value(); if (currentValue != null) { IN reduced = userFunction.reduce(currentValue, value); values.update(reduced); output.collect(element.replace(reduced)); } else { values.update(value); output.collect(element.replace(value)); } } }
@Override public V apply(V previousState, V value) throws Exception { return previousState != null ? reduceFunction.reduce(previousState, value) : value; } }
@Override public V apply(V previousState, V value) throws Exception { return previousState != null ? reduceFunction.reduce(previousState, value) : value; } }
@Override public V apply(V previousState, V value) throws Exception { return previousState != null ? reduceFunction.reduce(previousState, value) : value; } }
@Override public void nextValue(Type value) throws Exception { if (currentValue != null) { currentValue = function.reduce(currentValue, value); } else { currentValue = value; } }
@Override public Tuple2<K, T> reduce(Tuple2<K, T> value1, Tuple2<K, T> value2) throws Exception { value1.f1 = this.wrappedFunction.reduce(value1.f1, value2.f1); return value1; } }
@Override public T merge(T value1, T value2) { try { return reduceFunction.reduce(value1, value2); } catch (Exception e) { throw new RuntimeException("Could not properly reduce the values.", e); } }
@Override public void collect(IT record) { numRecordsIn.inc(); try { if (base == null) { base = serializer.copy(record); } else { base = objectReuseEnabled ? reducer.reduce(base, record) : serializer.copy(reducer.reduce(base, record)); } } catch (Exception e) { throw new ExceptionInChainedStubException(taskName, e); } }
@Override public void add(V value) throws Exception { byte[] key = getKeyBytes(); V oldValue = getInternal(key); V newValue = oldValue == null ? value : reduceFunction.reduce(oldValue, value); updateInternal(key, newValue); }
@Override public void flatMap(S s, Collector<S> collector) throws Exception { if (getWrappedFunction() != null) { summary = getWrappedFunction().reduce(s, summary); collector.collect(summary); if (transientState) { summary = initialVal; } } else { collector.collect(s); } }