InputFormat解读

<div class="iteye-blog-content-contain" style="font-size: 14px"></div>

     mapreduce  第一个步骤读取文件系统,解析成一个个key,value

    InputFormat 子类就是处理这件事的。 InputFormat 两个核心抽象方法getSplits,creatRecordReader

   1>getSplits方法:split the set of input files for the job. >Each {@link InputSplit} is then assigned to an individual {@link Mapper} for processing意思读取文件对原数据的切分一个个InputSplit

  一个InputSplit 对应一个map 进程去处理.通过阅读FileInputSplit 源代码getSplit方法,可以知道

1个文件可以切分1个或者多个InputSplit,

更加抽象的得到:有多个block,就有几个InputSplit(默认配置),就有个多少map任务.

  2> createRecordReader方法:对于InputSplit解析key,value

Map任务是静态,Map进程动态.

 为啥Maper k1,v1是LongWritable,Text

因为job默认处理类TextInputFormat<LongWritable,Text>已经定死了。

猜你喜欢

转载自liyunqiangyq.iteye.com/blog/2200379