T - Type of the elements that this function processes.O - The type of the elements returned by the user-defined function.@Public public interface GroupReduceFunction<T,O> extends Function, Serializable
For a reduce functions that works incrementally by combining always two elements, see
ReduceFunction.
The basic syntax for using a grouped GroupReduceFunction is as follows:
DataSet<X> input = ...;
DataSet<X> result = input.groupBy(<key-definition>).reduceGroup(new MyGroupReduceFunction());
Partial computation can significantly improve the performance of a GroupReduceFunction.
This technique is also known as applying a Combiner.
Implement the GroupCombineFunction interface to enable partial computations, i.e.,
a combiner for this GroupReduceFunction.| Modifier and Type | Method and Description |
|---|---|
void |
reduce(Iterable<T> values,
Collector<O> out)
The reduce method.
|
void reduce(Iterable<T> values, Collector<O> out) throws Exception
values - All records that belong to the given input key.out - The collector to hand results to.Exception - This method may throw exceptions. Throwing an exception will cause the operation
to fail and may trigger recovery.Copyright © 2014–2016 The Apache Software Foundation. All rights reserved.