Hadoop PIG Max of Tuple

如何在Pig中找到元组的MAX?

我的代码看起来像这样:

A,20
B,10
C,40
D,5

data = LOAD 'myData.txt' USING PigStorage(',') AS key, value;
all = GROUP data ALL;
maxKey = FOREACH all GENERATE MAX(data.value);
DUMP maxKey;

这返回40,但我想要完整的键值对:C,40.有任何想法吗?

这适用于Pig 0.10.0:

data = LOAD 'myData.txt' USING PigStorage(',') AS (key, value: long);
A = GROUP data ALL;
B = FOREACH A GENERATE MAX(data.value) AS val;
C = FILTER data BY value == (long)C.val;
DUMP C;
相关文章
相关标签/搜索