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
..
..
..
有没有办法不用Pig或Hive?我在用java。
2条答案
按热度按时间nhaq1z211#
您可以通过多个输入来实现这一点,请参见这里的示例
6jjcrrmo2#
据我所知,在reducer类中不能有输出数组。我想解决你的问题有以下几点:
mr1的输出键是
{a,b,c}
价值是成对的{timestamp,idCount}
或者{timestamp, loginCount}
或者{timestamp, someCount}
根据钥匙。你要把mr2-4合并起来。所以过程是这样的:
还有一些方法称为
Partitioner and GroupComperator
其中可以使用{key/value}和mapper/reducerkey+some_part_of_value
作为关键。