![](/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.