2012-11-21 34 views

回答

5

我也在尋找相同的東西。我確實得到了答案,儘管晚了,我還是認爲分享這可能會幫助某人。

從Hadoop的2.0起,你可以找到ChainMapper和ChainReducer在包org.apache.hadoop.mapreduce.lib.chain

ChainMapper使用模式:
... 
Job job = new Job(conf, "MyJob"); 

Configuration map1Conf = new Configuration(false); 
... ChainMapper.addMapper(job, AMap.class, LongWritable.class, Text.class, Text.class, Text.class, true, map1Conf); 

Configuration map2Conf = new Configuration(false); 
... ChainMapper.addMapper(job, BMap.class, Text.class, Text.class, LongWritable.class, Text.class, false, map2Conf); 

Configuration map3Conf = new Configuration(false); 
... ChainReducer.setReducer(job, CReducer.class, Text.class, Text.class, LongWritable.class, Text.class, false, map3Conf); 
... 

job.waitForComplettion(true); 
... 
0

請閱讀這個post。這顯示瞭如何使用兩個JobConf來啓用Map Reduce Jobs的鏈接,而不是使用ChainMapper/ChainReducer。

+0

但addDependingJob只是保證一個被執行之後又一次使用ChainReducer將一個輸出直接傳遞到另一個輸入,以減少磁盤使用量。 –