Interface GroupReduceFunction<T,O>
-
- Type Parameters:
T- Type of the elements that this function processes.O- The type of the elements returned by the user-defined function.
- All Superinterfaces:
Function,Serializable
- All Known Implementing Classes:
RichGroupReduceFunction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@Public @FunctionalInterface public interface GroupReduceFunction<T,O> extends Function, Serializable
The interface for group reduce functions. GroupReduceFunctions process groups of elements. They may aggregate them to a single value, or produce multiple result values for each group. The group may be defined by sharing a common grouping key, or the group may simply be all elements of a data set.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 theGroupCombineFunctioninterface to enable partial computations, i.e., a combiner for thisGroupReduceFunction.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidreduce(Iterable<T> values, Collector<O> out)The reduce method.
-
-
-
Method Detail
-
reduce
void reduce(Iterable<T> values, Collector<O> out) throws Exception
The reduce method. The function receives one call per group of elements.- Parameters:
values- All records that belong to the given input key.out- The collector to hand results to.- Throws:
Exception- This method may throw exceptions. Throwing an exception will cause the operation to fail and may trigger recovery.
-
-