Hadoop(19)-MapReduce框架原理-Combiner合并
生活随笔
收集整理的這篇文章主要介紹了
Hadoop(19)-MapReduce框架原理-Combiner合并
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1. Combiner概述
?
?2. 自定義Combiner實現步驟
1). 定義一個Combiner繼承Reducer,重寫reduce方法
public class WordcountCombiner extends Reducer<Text, IntWritable, Text,IntWritable>{@Overrideprotected void reduce(Text key, Iterable<IntWritable> values,Context context) throws IOException, InterruptedException {// 1 匯總操作int count = 0;for(IntWritable v :values){count += v.get();}// 2 寫出context.write(key, new IntWritable(count));} }2). 在Driver類中添加設置
job.setCombinerClass(WordcountCombiner.class);?
效果
?
?
?
轉載于:https://www.cnblogs.com/duoduotouhenying/p/10110510.html
總結
以上是生活随笔為你收集整理的Hadoop(19)-MapReduce框架原理-Combiner合并的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: centos 6.5升级openssl
- 下一篇: Python爬虫入门教程 1-100 C