The abstract Reducer class is used to build reducers for the {@link Job}.
Reducers may be distributed inside of the cluster but there is always only one Reducer per key.
Reducers are called in a threadsafe way so internal locking is not required.
Due to the fact that there is only one Reducer per key mapped values needs to be transmitted to one of the cluster nodes. To reduce the traffic costs between the nodes a {@link Combiner} implementation can be added to the call which runs alongsidethe mapper to pre-reduce mapped values into intermediate results.
A simple Reducer implementation could look like that sum-function implementation:
public class SumReducer implements Reducer<String, Integer, Integer> { private int sum = 0; public void reduce( String key, Integer value ) { sum += value; } public Integer finalizeReduce() { return sum; } }
@param < KeyIn> key type of the resulting keys
@param < ValueIn> value type of the incoming values
@param < ValueOut> value type of the reduced values
@since 3.2