RecordReader 在 Hadoop 中的工作 [英] Working of RecordReader in Hadoop

查看:10
本文介绍了RecordReader 在 Hadoop 中的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释一下 RecordReader 是如何工作的?程序开始执行后nextkeyvalue()getCurrentkey()getprogress()方法是如何工作的?

Can anyone explain how the RecordReader actually works? How are the methods nextkeyvalue(), getCurrentkey() and getprogress() work after the program starts executing?

推荐答案

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

(new API): The default Mapper class has a run method which looks like this:

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

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

The Context.nextKeyValue(), Context.getCurrentKey() and Context.getCurrentValue() methods are wrappers for the RecordReader methods. See the source file src/mapred/org/apache/hadoop/mapreduce/MapContext.java.

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

So this loop executes and calls your Mapper implementation's map(K, V, Context) method.

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

Specifically, what else would you like to know?

这篇关于RecordReader 在 Hadoop 中的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆