Combiner 合并
父类Reducer
局部汇总,减少网络传输量,今儿优化程序
注意:求平均值?
不可以,疯了吧
public class WordCountCombiner extends Reducer<Text, IntWritable, Text, IntWritable>{
@Override
public void reduce(Text key, Interable<IntWritable> values, Context context)
throws IOException, InterruptedException{
int count = 0;
for(IntWritable v : values){
count += v;
}
context.write(key, new IntWritable(count));
}
}
Diriver类{
job.setCombinerClass(WordCountCombiner.class);
job.serCombinerClass(WordCountReducer.class);
}