T- Type of the elements that this function processes.
@Public public interface ReduceFunction<T> extends Function, Serializable
For a reduce functions that work on an entire group at the same time (such as the
MapReduce/Hadoop-style reduce), see
GroupReduceFunction. In the general case,
ReduceFunctions are considered faster, because they allow the system to use more efficient
The basic syntax for using a grouped ReduceFunction is as follows:
DataSet<X> input = ...; DataSet<X> result = input.groupBy(<key-definition>).reduce(new MyReduceFunction());
Like all functions, the ReduceFunction needs to be serializable, as defined in
|Modifier and Type||Method and Description|
The core method of ReduceFunction, combining two values into one value of the same type.
T reduce(T value1, T value2) throws Exception
value1- The first value to combine.
value2- The second value to combine.
Exception- This method may throw exceptions. Throwing an exception will cause the operation to fail and may trigger recovery.
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.