标签:
hdfs原始数据
hello a
hello b
map阶段:
输入数据:<0,"hello a">
<8,"hello b">
key为偏移量
输出数据:
map(key,value,context)
{
String[] words = value.split("\t");
for(String word :words)
{
//hello
//a
//hello
//b
输出conetxt.write(key,vlaue)
}
}
<hello,1>
<a,1>
<hello,1>
<b,1>
reduce阶段:(分组排序,字典序排序)
输入数据:
<a,1>
<b,1>
<hello,{1,1}>
输出数据:
reduce(key,value,context)
{
int sum=0;
String word=key;
for(int i:value)
{
sum+=i;
}
context.write(key,sum);
}
标签:
原文地址:http://www.cnblogs.com/yuanfuqiang/p/5913613.html