我是新来的Pig,我有一个文本文件,其中每一行包含一个不同的信息记录,格式如下:
name, year, count, uniquecount
例如:
Zverkov winced_VERB 2004 8 8
Zverkov winced_VERB 2008 4 4
Zverkov winced_VERB 2009 1 1
zvlastni _ADV_ 1913 1 1
zvlastni _ADV_ 1928 2 2
zvlastni _ADV_ 1929 3 2
我想按唯一名称对所有记录进行分组,然后为每个唯一名称计算count/uniquecount,最后按此计算值对输出进行排序。
以下是我一直在尝试的:
bigrams = LOAD 'input/bigram/zv.gz' AS (bigram:chararray, year:int, count:float, books:float);
group_bigrams = GROUP bigrams BY bigram;
average_bigrams = FOREACH group_bigrams GENERATE group, SUM(bigrams.count) / SUM(bigrams.books) AS average;
sorted_bigrams = ORDER average_bigrams BY average;
1条答案
按热度按时间7qhs6swi1#
似乎我的原始代码确实产生了所需的输出,只做了一个小改动: