+3 votes
in Hadoop by
Explain the core methods of a Reducer.

2 Answers

0 votes
by

There are three core methods of a reducer. They are-

  1. setup() – This is used to configure different parameters like heap size, distributed cache and input data.
  2. reduce() – A parameter that is called once per key with the concerned reduce task
  3. cleanup() – Clears all temporary files and called only at the end of a reducer task.
0 votes
by

The API of Reducer is very similar to that of Mapper, there's a run() method that receives a Context containing the job's configuration as well as interfacing methods that return data from the reducer itself back to the framework. The run() method calls setup() once, reduce() once for each key associated with the reduce task, and cleanup() once at the end. Each of these methods can access the job's configuration data by using Context.getConfiguration(). As in Mapper, any or all of these methods can be overridden with custom implementations. If none of these methods are overridden, the default reducer operation is the identity function; values are passed through without further processing. The heart of Reducer is its reduce() method. This is called once per key; the second argument is an Iterable which returns all the values associated with that key.

...