簡體   English   中英

MapReduce中的合並器和映射器合並器之間的區別?

[英]Difference between combiner and in-mapper combiner in mapreduce?

我是hadoop和mapreduce的新手。 有人可以澄清組合器和映射器中的組合器之間的區別嗎,或者它們是同一回事?

您可能已經知道,合並器是在每台Mapper機器上本地運行的進程,用於在將數據通過網絡重新整理到各個Cluster Reducer之前對其進行預聚合。

映射器內組合器進一步優化了該聚合:聚合甚至沒有寫入本地磁盤:聚合發生 Mapper本身的內存中。

映射器內組合器通過利用以下內容的setup()和cleanup()方法來實現此目的

org.apache.hadoop.mapreduce.Mapper

按照以下幾行來創建內存映射:

Map<LongWritable, Text> inmemMap = null
   protected void setup(Mapper.Context context) throws IOException, InterruptedException {
   inmemMap  = new Map<LongWritable, Text>();
 }

然后,在每次map()調用期間,您都向內存映射中的對象添加值(而不是對每個值調用context.write()。最終,Map / Reduce框架將自動調用:

protected void cleanup(Mapper.Context context) throws IOException, InterruptedException {
  for (LongWritable key : inmemMap.keySet()) {
      Text myAggregatedText = doAggregation(inmemMap.get(key))// do some aggregation on 
                   the inmemMap.     
      context.write(key, myAggregatedText);
  }
}

注意,不是每次都調用context.write(),而是將條目添加到內存映射中。 然后在cleanup()方法中調用context.write(),但具有內存映射中的壓縮/預聚合結果。 因此,本地地圖輸出假脫機文件(將由reducer讀取)將小得多。

在這兩種情況下(在內存和外部組合器中),由於較小的映射假脫機文件,您將獲得減少到簡化器的網絡流量的好處。 這也減少了減速器的處理。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM