OutputFormat数据输出
OutputFormat概述
OutputFormat
是MapReduce
输出的基类,所有实现MapReduce
输出都实现了OutputFormat
接口。
在MR
中默认的使用的OutputFormat
子类是TextOutputFormat
。
源码分析
打开IDEA
,双击两下Shift
键搜索OutputFormat
查看源码,然后将光标防放在OutputFormat
类名上按Ctrl + H
查看层次结构。
Input ---> InputFormat --->Mapper--->Shuffle--->Reducer--->OutputFormat--->Output
Map阶段---->Reduce阶段
Map阶段 ---> Shuffle(Map后半段+Reduce前半段)--->Reduce阶段
MapTask
:map ---> sort
1 | mapPhase = getProgress().addPhase("map", 0.667f); |
ReduceTask
: copy ---> sort ---> reduce
1 | copyPhase = getProgress().addPhase("copy"); |
Hadoop
的运行模式包括:本地模式
、伪分布式
以及完全分布式