首先运行的是:分区器还是组合器?

use*_*694 9 hadoop

我想在分区器和组合器之间运行,它首先运行?

我认为它首先是分离器然后是组合器,然后键被重定向到不同的reducer,它们看起来像分区器,所以我很困惑.请帮我理解.

add*_*015 26

您问题的直接答案是=> COMBINER

细节:可以在地图阶段将组合器视为迷你减速器.它们在进一步分发之前对映射器结果执行local-reduce.一旦执行了Combiner功能,它就会被传递给Reducer以进行进一步的工作.

在哪里

当我们在减速机上工作时,分区器就会出现在图片中.因此,分区程序决定哪个reducer负责特定键.它们基本上采用Mapper结果(如果使用Combiner然后使用Combiner Result)并根据键将其发送到负责的Reducer.

为了更好地理解,您可以参考下面的图片,这是我从Hadoop上的Yahoo Developer Tutorial中获取的. 图4.6:插入MapReduce数据流的组合器步骤

这是教程.

  • JFYI:然而有一个扭曲:Combiner也可以在减速机侧运行.中间输出被复制到reducer的JVM的内存中.当内存缓冲区达到阈值大小时,内部输出将合并并溢出到磁盘.如果指定了组合器,它将在合并期间运行,以减少写入磁盘的数据量. (3认同)

小智 5

分区排在第一位.

根据"Hadoop,权威指南",Mapper的输出首先写入内存缓冲区,然后当缓冲区即将溢出时溢出到本地目录.根据分区程序将溢出数据分开,并且在每个分区中,如果给出Combiner,则对结果进行排序和组合.

您只需修改wordcount MR程序即可对其进行验证.我的结果是:("快速的棕色狐狸跳过一只懒狗")


单词,步骤,时间

福克斯,Mapper,**********754

狐狸,分区,**********754

fox,Combiner,**********850

狐狸,减速器,**********904


显然,Combiner在Partitioner之后运行.


小智 5

Partitioner之前运行CombinerMapReduce 综合图

您可以拥有自定义分区逻辑,在对映射器结果进行分区后,对分区进行排序并将其Combiner应用于排序后的分区。

请参阅Hadoop MapReduce 综合说明

Combiner我通过运行带有自定义和时间戳记录的字数统计程序来检查它Partitioner

Apr 23, 2018 2:41:22 PM mapreduce.WordCountPartitioner getPartition
INFO: Partitioner: 1524483682580 : hello : 1
Apr 23, 2018 2:41:22 PM mapreduce.WordCountPartitioner getPartition
INFO: Partitioner: 1524483682582 : hello : 1
Apr 23, 2018 2:41:22 PM mapreduce.WordCountPartitioner getPartition
INFO: Partitioner: 1524483682583 : hello : 1
Apr 23, 2018 2:41:22 PM mapreduce.WordCountPartitioner getPartition
INFO: Partitioner: 1524483682583 : world : 1
Apr 23, 2018 2:41:22 PM mapreduce.WordCountPartitioner getPartition
INFO: Partitioner: 1524483682584 : world : 1
Apr 23, 2018 2:41:22 PM mapreduce.WordCountPartitioner getPartition
INFO: Partitioner: 1524483682585 : hello : 1
Apr 23, 2018 2:41:22 PM mapreduce.WordCountPartitioner getPartition
INFO: Partitioner: 1524483682585 : world : 1
18/04/23 14:41:22 INFO mapred.LocalJobRunner: 
18/04/23 14:41:22 INFO mapred.MapTask: Starting flush of map output
18/04/23 14:41:22 INFO mapred.MapTask: Spilling map output
18/04/23 14:41:22 INFO mapred.MapTask: bufstart = 0; bufend = 107; bufvoid = 104857600
18/04/23 14:41:22 INFO mapred.MapTask: kvstart = 26214396(104857584); kvend = 26214368(104857472); length = 29/6553600
Apr 23, 2018 2:41:22 PM mapreduce.WordCountCombiner reduce
INFO: Combiner: 1524483682614 : hello 
Apr 23, 2018 2:41:22 PM mapreduce.WordCountCombiner reduce
INFO: Combiner: 1524483682615 : world
Run Code Online (Sandbox Code Playgroud)