0
votes

Just a basic question.I know the Mapper and the Reducer are Interfaces in the Hadoop version 2. But still when coding I see examples using extends mapper or extends reducer instead of implements.Is there a reason for this or are they being implemented as in the old version due to backward compatibility? Here is the link where I've been studying https://hadoop.apache.org/docs/current/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html#MapReduce_-_User_Interfaces

3
org.apache.hadoop.mapreduce.* is the package you should use for Hadoop2, and those are not interfaces. - OneCricketeer

3 Answers

1
votes

Not sure where you are reading on that page that the Mapper and Reducer are interfaces for MapReduce2, but the source code on that page clearly uses classes. Keyword being extends.

import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
...
public static class TokenizerMapper extends Mapper
...
public static class IntSumReducer extends Reducer

It should be mentioned that the org.apache.hadoop.mapred.Mapper and org.apache.hadoop.mapred.Reducer are interfaces, but those are meant to be used for MapReduce1.

I think the purpose of re-writing the Mapper and Reducer as classes was to simplify class creation without using extends MapReduceBase implements like so

class MyReducer<K extends WritableComparable, V extends Writable> 
     extends MapReduceBase implements Reducer<K, V, K, V> 
0
votes

I found this when having a closer look at the APIs. org.apache.hadoop.mapreduce Class Reducer is for Hadoop2 where Mapper and the Reducer are Classes and org.apache.hadoop.mapred Interface Reducer was there in Hadoop 1 where they were interfaces which compiles in Hadoop 2 as well. It's just the difference between the old API and the new one that supports backward compatibility

0
votes

Yes -Mapper and Reducer were classes in HADOOP-1x and it has been enhanced to INTERFACE in later HADOOP -2x versions

EXAMPLE -CODE:

In previous versions of HADOOP

public static class New_Map extends MapReduceBase implements Mapper{

In HADOOP-2x

public static class New_Map extends Mapper{