mapreduce系列(2)shuffle流程及Combiner
来源:互联网 发布:天刀洛天依捏脸数据 编辑:程序博客网 时间:2024/06/05 23:04
一、shuffle流程原理
二、Combiner的使用
package wc;import org.apache.hadoop.io.IntWritable;import org.apache.hadoop.io.Text;import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;/** * combiner可以在在maptask在环形缓冲区溢出时和归并时进行相同key-value值得合并(和reduce功能类似), * 这样可以大大减少map到reduce的数据量。 * Created by tianjun on 2017/3/17. */public class WordcountCombiner extends Reducer<Text,IntWritable,Text,IntWritable>{ @Override protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException { int count = 0 ; for(IntWritable v: values){ count += v.get(); } context.write(key,new IntWritable(count)); }}
在driver类中加上
//设置combiner(由于WordcountCombiner和WordCountReducer实现的功能一模一样,所以可以直接用WordCountReducer替代) wcjob.setCombinerClass(WordcountCombiner.class); //wcjob.setCombinerClass(WordCountReducer.class);
本例由于是统计单词的次数,不会影响业务逻辑,所以Combiner可以放心使用。
0 0
- mapreduce系列(2)shuffle流程及Combiner
- mapreduce中的partitioner,combiner,shuffle
- 关于mapreduce 的 shuffle ,partition,combiner
- MapReduce combiner阶段 与shuffle阶段的区别
- MapReduce中的combiner、partition和shuffle各自的作用是什么?
- InputSplit&&处理阶段mapReduce【partioner,combiner,shuffle】->reduce
- 【MR】MapReduce中shuffle、partition、combiner的作用与关系
- mapreduce的规约(Combiner)
- MapReduce作业Map阶段和Reduce阶段重要过程详述(Partitioner、Combiner、Shuffle三个阶段的解析)
- Mapreduce中Combiner的使用及误区
- Mapreduce中Combiner的使用及误区
- Mapreduce中Combiner的使用及误区
- Mapreduce中Combiner的使用及误区
- MapReduce: combiner
- MapReduce--Combiner
- combiner/Partitioner/shuffle
- MapReduce优化实例(自定义Partition Combiner)
- mapreduce的执行流程以及shuffle过程
- java 假随机
- Solr快速入门(一)
- LINQ查询语法
- 架构分布式____HA和KeepAlive实现高可用负载均衡
- sun.misc.BASE64Encoder找不到jar包的解决方法
- mapreduce系列(2)shuffle流程及Combiner
- Java正则表达式过滤出字母、数字和中文
- mysql的limit
- oracle数据库表被锁的解决方法
- opencv求逆矩阵
- 九度1035
- Flutter进阶—使用自定义字体
- 【九度OJ】题目1178:复数集合 解题报告
- Struts2中<s-if>和<s-iterator>标签的使用