在Hadoop中使用RecordReader

Amn*_*iac 9 hadoop mapreduce

任何人都可以解释RecordReader如何实际工作?这些方法如何nextkeyvalue(),getCurrentkey()getprogress()在程序开始执行后工作?

Chr*_*ite 14

(新API):默认的Mapper类有一个run方法,如下所示:

public void run(Context context) throws IOException, InterruptedException {
    setup(context);
    while (context.nextKeyValue()) {
        map(context.getCurrentKey(), context.getCurrentValue(), context);
    }
    cleanup(context);
}
Run Code Online (Sandbox Code Playgroud)

Context.nextKeyValue(),Context.getCurrentKey()Context.getCurrentValue()方法的包装RecordReader方法.查看源文件src/mapred/org/apache/hadoop/mapreduce/MapContext.java.

所以这个循环执行并调用Mapper实现的map(K, V, Context)方法.

具体来说,您还想知道什么?

  • getProgress()怎么样? (2认同)