MapReduce(3): Partitioner, Combiner and Shuffling

Partitioner:

Partitioning and Combining take place between Map and Reduce phases. It is to club the data which should go to the same reducer based on keys. The number of partitioners is equal to the number of reducers. That means a partitioner will divide the data according to the number of reducers. Therefore, the data passed from a single partitioner is processed by a single Reducer. HashPartitioner is the default Partitioner in hadoop.

A partitioner partitions the key-value pairs of intermediate Map-outputs. It partitions the data using a user-defined condition, which works like a hash function. The total number of partitions is same as the number of Reducer tasks for the job. Records having the same key value go into the same partition (within each mapper).

Partition doing jobs on local machine.

Combiner:

Combiner is a ‘mini-reducer‘ (semi-reducer), used to process reducer‘s work before transfering data onto reducers. It can reduce network congestion. An example is shown below:

Shuffle:

shuffle notify master to copy files onto reducer machines. In the final output of map task there can be multiple partitions and these partitions should go to different reduce task. Shuffling is basically transferring map output partitions to the corresponding reduce tasks. Map task notified application master about completion of map task and application master notifies corresponding reducer to copy the map output into reduce machine.

References:

https://www.cnblogs.com/hadoop-dev/p/5910459.html

https://blog.csdn.net/bitcarmanlee/article/details/60137837

http://geekdirt.com/blog/map-reduce-in-detail/

Using hash function to map immediate K,V pairs

https://en.wikipedia.org/wiki/Hash_function

https://www.tutorialspoint.com/map_reduce/map_reduce_partitioner.htm

https://data-flair.training/blogs/hadoop-partitioner-tutorial/

原文地址:https://www.cnblogs.com/rhyswang/p/10946833.html

时间: 2024-08-03 08:18:51

MapReduce(3): Partitioner, Combiner and Shuffling的相关文章

Hadoop初学指南(8)--MapReduce中的Combiner操作

本文主要介绍了MapReduce中的Combiner操作. 在MapReduce的执行步骤中,我们一共分了8步,其中Map中的最后一步规约操作就是今天要讲的Combiner. 首先看一下前文中的计数器: 我们可以发现,其中有两个计数器:Combine output records和Combine input records,他们的计数都是0,这是因为我们在代码中没有进行规约操作. 现在我们加入规约操作. 在前文代码(参看http://xlows.blog.51cto.com/5380484/14

MapReduce教程(二)MapReduce框架Partitioner分区<转>

1 Partitioner分区 1.1 Partitioner分区描述 在进行MapReduce计算时,有时候需要把最终的输出数据分到不同的文件中,按照手机号码段划分的话,需要把同一手机号码段的数据放到一个文件中:按照省份划分的话,需要把同一省份的数据放到一个文件中:按照性别划分的话,需要把同一性别的数据放到一个文件中.我们知道最终的输出数据是来自于Reducer任务.那么,如果要得到多个文件,意味着有同样数量的Reducer任务在运行.Reducer任务的数据来自于Mapper任务,也就说Ma

MapReduce程序之combiner规约

[toc] MapReduce程序之combiner规约 前言 前面的wordcount程序,shuffle阶段的数据都是<hello, [1, 1, 1]>这种类型的(可以查看程序的输出),也就是说,交给reduce处理时就是这种类型的数据,这会带来一个问题,什么问题呢?就是网络传输问题,对于[1, 1, 1]这种数据,完全可以在本地就先完成规约,即将相当于在本地做一次reduce,从代码的角度去分析,其实也是一次reduce的操作,只是这个过程是在shuffle的时候就完成的. 程序代码

[MapReduce_5] MapReduce 中的 Combiner 组件应用

0. 说明 Combiner 介绍 &&  在 MapReduce 中的应用 1. 介绍 Combiner: Map 端的 Reduce,有自己的使用场景 在相同 Key 过多的情况下,在 Map 端进行的预聚合,大大缓解了网络间的 K-V 全分发 Combiner 适用场景: 最大值 求和 最小值 Combiner 不适用平均值的计算 2. 结合 Combiner 实现 Word Count 在 [MapReduce_1] 运行 Word Count 示例程序 代码基础上在 WCApp.

mapreduce中的combiner、partitioner、Shuffle

一.combiner combiner不是mapreduce的一个必备过程,是由开发者选择是否使用的,是mapreduce的一种优化手段. combiner的作用:combiner是为了解决mapreduce过程中的两个性能瓶颈,1.网络宽带严重被占降低程序效率,2.单一节点承载过重降低程序效率.所以性能有以下两个作用: 1.combiner实现本地key的聚合,对map输出的key排序value进行迭代 2.combiner还有本地reduce功能(其本质上就是一个reduce). 什么时候运

MapReduce之Partitioner组件

简述 Partitioner组件可以让Map对Key进行分区,从而可以根据不同的key来分发到不同的reduce中去处理: 你可以自定义key的一个分发规则,如数据文件包含不同的大学,而输出的要求是每个大学输出一个文件: Partitioner组件提供了一个默认的HashPartitioner. package org.apache.hadoop.mapreduce.lib.partition; public class HashPartitioner<K, V> extends Partit

MapReduce的Partitioner案例

项目简介 这里给出一个经典的词频统计的案例:统计如下样本数据中每个单词出现的次数. SparkHBase HiveFlinkStormHadoopHBaseSpark Flink HBaseStorm HBaseHadoopHiveFlink HBaseFlinkHiveStorm HiveFlinkHadoop HBaseHive HadoopSparkHBaseStorm HBaseHadoopHiveFlink HBaseFlinkHiveStorm HiveFlinkHadoop HBa

MapReduce框架Partitioner分区方法

前言:对于二次排序相信大家也是似懂非懂,我也是一样,对其中的很多方法都不理解诶,所有只有暂时放在一边,当你接触到其他的函数,你知道的越多时你对二次排序的理解也就更深入了,同时建议大家对wordcount的流程好好分析一下,要真正的知道每一步都是干什么的. 1.Partitioner分区类的作用是什么? 2.getPartition()三个参数分别是什么? 3.numReduceTasks指的是设置的Reducer任务数量,默认值是是多少? 扩展: 如果不同类型的数据被分配到了同一个分区,输出的数

MapReduce分区方法Partitioner方法

前言:对于二次排序相信大家也是似懂非懂,我也是一样,对其中的很多方法都不理解诶,所有只有暂时放在一边,当你接触到其他的函数,你知道的越多时你对二次排序的理解也就更深入了,同时建议大家对wordcount的流程好好分析一下,要真正的知道每一步都是干什么的. 1.Partitioner分区类的作用是什么? 2.getPartition()三个参数分别是什么? 3.numReduceTasks指的是设置的Reducer任务数量,默认值是是多少? 扩展: 如果不同类型的数据被分配到了同一个分区,输出的数