我在hadoop中挣扎着这样的事情
由于我的映射器,我得到了关注
KeyValue1, 2014-02-01 20:42:00
KeyValue1, 2014-02-01 20:45:12
KeyValue1, 2014-05-01 10:35:02
KeyValue2, 2014-03-01 01:45:12
KeyValue2, 2014-03-01 02:08:18
KeyValue3, 2014-02-01 20:45:12
KeyValue4, 2015-02-01 05:45:12
KeyValue4, 2013-02-01 10:45:12
并继续..
归根结底,我想要这个;
KeyValue1, TimeDifference(first occurrence - last occurrence)
KeyValue2, TimeDifference(first occurrence - last occurrence)
KeyValue3, -occured once-
KeyValue4, TimeDifference(first occurrence - last occurrence)
任何意见都非常感谢。干杯
有多种方法。我建议使用组合键。创建自定义分区器、键比较器和组比较器。然后在减速器侧,您可以简单地选择第一行和最后一行并取差异。