Hadoop中Mapper类的setup()函数在什么地方调用
2013-04-28 09:36
211 查看
经过跟踪hadoop源码发现,Mapper类的setup()函数在Mapper类的run()函数中被调用。
向hadoop提交job后,hadoop会在MapTask的runNewMapper()或者runOldMapper()函数中使用反馈机制实例化具体的Mapper子类,然后调用这个对象的run()函数,其中setup()函数就在这个函数的开始被调用,因为hadoop会向setup()函数中传递Configuration等一些变量,所以我们可以通过重载setup()函数来获得系统变量实现自己的功能。
向hadoop提交job后,hadoop会在MapTask的runNewMapper()或者runOldMapper()函数中使用反馈机制实例化具体的Mapper子类,然后调用这个对象的run()函数,其中setup()函数就在这个函数的开始被调用,因为hadoop会向setup()函数中传递Configuration等一些变量,所以我们可以通过重载setup()函数来获得系统变量实现自己的功能。
/** * Expert users can override this method for more complete control over the * execution of the Mapper. * @param context * @throws IOException */ public void run(Context context) throws IOException, InterruptedException { setup(context);//只运行一次,可以重载实现自己的功能,比如获得Configuration中的参数 while (context.nextKeyValue()) { map(context.getCurrentKey(), context.getCurrentValue(), context); } cleanup(context); }http://blog.csdn.net/witsmakemen/article/details/8445133
相关文章推荐
- Hadoop中Mapper类的setup()函数在什么地方调用
- Hadoop中Mapper类的setup()函数在什么地方调用
- Hadoop中Mapper类的setup()函数在什么地方调用
- Hadoop中Mapper类的setup()函数在什么地方调用
- Xcode查找函数调用以及被调用的地方
- probe()函数是什么时候被调用,设备和驱动是怎么联系起来的
- C语言的函数调用和oc的消息机制有什么区别
- Javascript中调用一个函数(对象),使用new或者直接调用有什么区别?
- 函数调用时,栈里到底发生了什么?
- 函数调用方式--__thiscall调用方式和__cdecl,__stdcall有什么区别
- Eclipse 查看变量或方法在什么地方被调用的快捷键
- 函数调用方式--__thiscall调用方式和__cdecl,__stdcall有什么区别
- 构造函数和析构函数中调用虚函数有什么问题
- 在vim中使用cscope查找调用、定义函数和变量的地方
- 调用malloc()函数之后,内核发生了什么?附malloc()和free()实现的源代码
- ViewController 的loadView、viewDidLoad、viewDidUnload分别是什么时候调用的,在自定义ViewCointroller时在这几个函数中应该做什么工作?
- 构造函数和析构函数中调用虚函数有什么问题?
- 函数调用时栈中存放了什么
- 函数调用的时候栈发生了什么?
- 函数调用方式--__thiscall调用方式和__cdecl,__stdcall有什么区别