importjava.io.IOException;
importorg.apache.hadoop.io.IntWritable;
importorg.apache.hadoop.io.Text;
importorg.apache.hadoop.mapreduce.Reducer
/**
*Text数据类型:字符串类型String
*IntWritablereduce阶段的输入类型int
*Textreduce阶段的输出数据类型String类型
*IntWritable输出词频个数Int型
*/
publicclassWorkCountReduceextendsReducer<Text,IntWritable,Text,IntWritable>{
/**
*key输入的键*value输入的值
*context上下文对象,用于输出键值对
*/
@Override
protectedvoidreduce(Textkey,Iterable<IntWritable>value,
Contextcontext)throwsIOException,InterruptedException{
intsum=0;
for(IntWritablenumber:value){
sum+=number.get();
}
//单词个数hadoop,10
context.write(key,newIntWritable(sum));
}
}