在Hadoop中使用RecordReader [英] Working of RecordReader in Hadoop
本文介绍了在Hadoop中使用RecordReader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
nextkeyvalue()
, getCurrentkey()
和 getprogress()
在程序开始执行后工作吗?解决方案
看起来像这样:
public void run(Context context)throws IOException,InterruptedException {
setup(context); $ context(),context.getCurrentValue(),context);
}
cleanup(context);
$ b $ Context.nextKeyValue $ c>, Context.getCurrentKey()
和 Context.getCurrentValue()
方法是 RecordReader
方法。查看源文件 src / mapred / org / apache / hadoop / mapreduce / MapContext.java
。 循环执行并调用Mapper实现的映射(K,V,Context)
方法。
你想知道吗?
Can anyone explain how the RecordReader actually works? How are the methods nextkeyvalue()
, getCurrentkey()
and getprogress()
work after the program starts executing?
解决方案 (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);
}
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
.
So this loop executes and calls your Mapper implementation's map(K, V, Context)
method.
Specifically, what else would you like to know?
这篇关于在Hadoop中使用RecordReader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文