【发布时间】:2016-06-15 23:35:53
【问题描述】:
我有一个 mapreduce 作业,它进行一些处理并生成 city:fruit 的复合键(实现 WritableComparable)以及关联的计数。现在我想将它与辅助 mapreduce 作业链接起来,该作业确定每种水果类型的计数最高的城市。
mapreduce 作业 1 的复合键输出示例:
+---------------------+-------+
| city:fruit composite| count |
+---------------------+-------+
| london:apples | 3 |
+---------------------+-------+
| london:bannanas | 2 |
+---------------------+-------+
| london:oranges | 15 |
+---------------------+-------+
| charleston:apples | 20 |
+---------------------+-------+
| charleston:bannanas | 1 |
+---------------------+-------+
| charleston:oranges | 3 |
+---------------------+-------+
| chicago:bannanas | 17 |
+---------------------+-------+
| chicago:apples | 5 |
+---------------------+-------+
| chicago:oranges | 11 |
+---------------------+-------+
作业 2 的期望输出:
+------------+----------+
| city | fruit |
+------------+----------+
| london | oranges |
+------------+----------+
| charleston | apples |
+------------+----------+
| chicago | bannanas |
+------------+----------+
我怎样才能做到这一点?在我的 SQL 头脑中,复合键将是两列,一列表示城市,一列表示水果。我会按水果分组,排序,然后抓住数量最多的那一行。我无法弄清楚这如何转化为 mapreduce 世界。任何建议将不胜感激!
【问题讨论】:
标签: java hadoop mapreduce hadoop2 composite-key