When Exactly Combiner is called in MapReduce?
合并器是使用与reducer相同的类制作的,并且几乎都是相同的代码。
但是,问什么时候在排序和洗牌之前或什么时候在减少之前准确地调用它呢?
如果在排序和洗牌之前i。例如,在映射器之后,它将如何获得
现在,如果它是在排序和随机播放后调用的。例如,在减速器之前,输出到组合器的是
实际上是在地图阶段之后,排序和洗牌之前。在map阶段之后,输出将通过管道传递到下一个sort and shuffle阶段,Combiner在该sort and shuffle阶段之前起作用。就像是Map-> Combiner-> Sort n Shuffle-> Reducer
Combiner就像一个预缩减器,它将在map阶段之后,sort和shuffle阶段之前不久应用。
它将应用于处理地图阶段的同一主机上,从而最大程度地减少了网络在下一阶段的处理过程中的数据传输(排序和减少)。
由于使用组合器的这种优化,实际的减速器阶段将减少处理负担,从而获得更好的性能。
即使您编写自定义的合并器,Map Reduce框架也不会一直调用合并器。如果溢出数量至少为3(默认值),它将确定调用组合器。您可以配置,可以通过
组合器的输出类型必须与映射器的输出类型匹配。 Hadoop无法保证组合器被应用了多少次,甚至根本没有被应用。
如果您的映射器扩展了
参考Hadoop文档:
When the map operation outputs its pairs they are already available in memory. For efficiency reasons, sometimes it makes sense to take advantage of this fact by supplying a combiner class to perform a reduce-type function. If a combiner is used then the map key-value pairs are not immediately written to the output. Instead they will be collected in lists, one list per each key value. When a certain number of key-value pairs have been written, this buffer is flushed by passing all the values of each key to the combiner's reduce method and outputting the key-value pairs of the combine operation as if they were created by the original map operation.
http://wiki.apache.org/hadoop/HadoopMapReduce