Wednesday 19 August 2015

What is Mapper class and map() method?



Mapper class
This is a cut-down view of the base Mapper class provided by Hadoop. For our own mapper implementations, we will subclass this base class and override the specified method as follows:
class Mapper<K1, V1, K2, V2>{                                                                                               void map (K1 key, V1 value, Context context)  throws IOException,InterruptedException{                                                                                                                                ……………                                                                                                                               …………….
}}
Although the use of Java generics can make this look a little opaque at first, there is actually not that much going on. class is defined in terms of the key/value input and output types. The first one is map input key, second one map input value, third one is map output key, fourth one is map output value.

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

                                                                                                                                                                    

1 comment: