Wednesday, 19 August 2015

What is Reducer Class and reduce() method?

Reducer class
The Reducer base class works very similarly to the Mapper class, and usually requires only
sub classes to override a single reduce method. Here is the cut-down class definition:

public class Reducer<K2, V2, K3, V3>
void reduce(K1 key, Iterable<V2> values,Context context)
throws IOException, InterruptedException

Notice the class definition in terms of the broader data flow (the reduce method accepts K2/V2 as reduce input key, reduce input value  and provides K3/V3 as reduce output key, reduce output value) while the actual reduce method takes only a single key and its associated list of values. The Context object is again the mechanism to output the result of the method.

 reduce( ) method

The reduce method takes an input key/value pair in its parameters. First one is reduce input key(map output key), second one is reduce input value(map output value) and the other parameter is an instance of the Context class that provides various mechanisms to communicate with the Hadoop framework.        

No comments:

Post a Comment