![](/img/trans.png)
[英]How combiner works when we use multiple inputs in Hadoop MapReduce
[英]Hadoop - how to use and reduce multiple inputs?
Mapper/Reducer 1 --> (key,value)
/ | \
/ | \
Mapper/Reducer 2 | Mapper/Reducer 4
-> (oKey,oValue) | -> (xKey, xValue)
|
|
Mapper/Reducer 3
-> (aKey, aValue)
我有一個日志文件,我與MR1聚合。 Mapper2,Mapper3,Mapper4將MR1的輸出作為輸入。 喬布斯被束縛住了。
MR1輸出:
User {infos of user:[{data here},{more data},{etc}]}
..
MR2輸出:
timestamp idCount
..
MR3輸出:
timestamp loginCount
..
MR4輸出:
timestamp someCount
..
我想結合MR2-4的輸出:最終輸出 - >
timestamp idCount loginCount someCount
..
..
..
沒有豬或蜂巢的方式嗎? 我正在使用Java。
您可以使用MultipleInputs 在此處查看示例
據我所知,你不能在reducer類中有輸出數組。 我想到的解決問題的方法如下:
根據密鑰,MR1的輸出密鑰將是{a,b,c}
並且值在{timestamp,idCount}
或{timestamp, loginCount}
或{timestamp, someCount}
。 你將結合MR2-4 。
所以這個過程就是這樣的:
MR1 <inputKey,inputValue,outputKey,outPutValue> where outputKey is
"a" for outValue`{timestamp,idCount}
"b" for outValue`{timestamp, loginCount}
"c" for outValue`{timestamp, someCount}
MR2-4<inputKey,inputValue,outputKey,outPutValue> if inputkey is "a" do MR2
if inputkey is "b" do MR3
if inputkey is "c" do MR4
此外,還有一些名為Partitioner and GroupComperator
方法,您可以在其中使用{key / value},mapper / reducer可以將key+some_part_of_value
視為鍵。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.