Working of RecordReader in Hadoop

前端 未结 2 2031
春和景丽
春和景丽 2021-02-08 19:20

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

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-08 20:09

    (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?

提交回复
热议问题