您的位置:首页 > 移动开发

MapReduce中Mapper类和Reducer类4函数解析

2012-05-12 19:56 351 查看
Mapper类4个函数的解析

protected void setup(Mapper.Context context) throws IOException,InterruptedException //Called once at the beginning of the task

protected void cleanup(Mapper.Context context)throws IOException,InterruptedException //Called once at the end of the task.

protected void map(KEYIN key, VALUEIN value Mapper.Context context)throws IOException,InterruptedException


//Called once for each key/value pair in the input split. Most applications should override this, but the default is the identity function.


public void run(Mapper.Context context)throws IOException,InterruptedException


//Expert users can override this method for more complete control over the execution of the Mapper.


执行顺序:setup --->   map/run   ----> cleanup

同理在Reduce类中也存在4个函数

protected void setup(Mapper.Context context) throws IOException,InterruptedException //Called once at the beginning of the task

protected void cleanup(Mapper.Context context)throws IOException,InterruptedException //Called once at the end of the task.

protected void map(KEYIN key, VALUEIN value Mapper.Context context)throws IOException,InterruptedException


//This method is called once for each key. Most applications will define their reduce class by overriding this method. The default implementation is an identity function. public void run(Mapper.Context context)throws IOException,InterruptedException


//Advanced application writers can use the [code]run(org.apache.hadoop.mapreduce.Reducer.Context)
method to control how the reduce task works[/code]

执行顺序:setup --->   map/run   ----> cleanup
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: