[英]How does mapper run() method process the last record?
public void run(Context context) throws IOException, InterruptedException
{
setup(context);
while (context.nextKeyValue()) {
map(context.getCurrentKey(), context.getCurrentValue(), context);
}
cleanup(context);
}
With above snippet when the mapper's run method is called, everytime it gets the next key,value pair by nextkeyvalue() function from recordreader and process the current key,value pair. 在上面的代码段中,当调用映射器的run方法时,每次它通过recordreader的nextkeyvalue()函数获取下一个键值对,并处理当前的键值对。 So in that case if we are processing the last record of a particular inputsplit the nextkeyvalue() function would return false and we would not be missing the last record in every inputsplit?
因此,在那种情况下,如果我们正在处理特定输入拆分的最后一条记录,那么nextkeyvalue()函数将返回false,并且在每个输入拆分中都不会丢失最后一条记录吗?
nextKeyValue()
either advances to the next key/value and returns true, or has reached the end and returns false. nextKeyValue()
前进到下一个键/值并返回true,或者已到达末尾并返回false。 Therefore when nextKeyValue()
returns true for the final time getCurrentKey()
and getCurrentValue()
will get the final key/value for the split. 因此,当
nextKeyValue()
在最后一次返回true时, getCurrentKey()
和getCurrentValue()
将获得拆分的最终键/值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.