总结Pig Tuple中的值

时间:2015-10-19 16:27:36

标签: hadoop apache-pig

我有Pig元组的以下输出:

 dump g:
 ()
 (97)
 (245)
 (870)
 (480)

 describe g:
 g: {long}

我想总结一下#的总数,所以我尝试了这个:

 h = foreach g generate SUM($0);

我收到了这个错误:

 Please use an explicit cast.

然后我尝试将值转换为(int)但仍然无法正常工作。

我正在寻找的输出是这样的:

 1692

以下是导致以下内容的代码:

 a = LOAD 'tellers' using TextLoader() AS line;
 # convert a to charrarry
 b = foreach a generate (chararray)line;  
 # run through my UDF to create tuples
 c = foreach b generate myudfs.TellerParser5(line);  # ({(20),(5),(5),(10)(1),(1),(1),(1),(1),(5),(10),(10),(10)})....
 d = foreach c generate flatten(number); 
 e = group d by number; #{group: chararray,d: {(number: chararray)}}
 f = foreach e generate group, COUNT(d);  # f: {group: chararray,long}
 g = foreach f generate (long)$0 * $1;

1 个答案:

答案 0 :(得分:1)

你需要做这样的事情:

angular-ui-router.min.js