Apache pig apachepig,程序问题
我不熟悉pig编程,我只是尝试了一个程序,输入如下Apache pig apachepig,程序问题,apache-pig,Apache Pig,我不熟悉pig编程,我只是尝试了一个程序,输入如下 ****Input:**gedit bomb** sasi:where is the bomb pras:bomb is with me sasi:what is the bomb time pras:it is set to nine. ****output:**** sasi:2 pras:1 这是每个名字(sasi、pras)出现“炸弹”一词的次数 像这样试试 A = load 'bomb' USING PigStorage(':
****Input:**gedit bomb**
sasi:where is the bomb
pras:bomb is with me
sasi:what is the bomb time
pras:it is set to nine.
****output:****
sasi:2
pras:1
这是每个名字(sasi、pras)出现“炸弹”一词的次数
像这样试试
A = load 'bomb' USING PigStorage(':') as (name:chararray,word:chararray);
B = GROUP A BY name;
C = FOREACH B{
filterByBomb = FILTER A by word MATCHES '.*bomb.*';
GENERATE group,COUNT(filterByBomb.word);
}
STORE C INTO 'output' USING PigStorage(':');
输出:
pras:1
sasi:2
感谢您的回复,现在获取以下错误:2014-11-17 00:10:18373[main]error org.apache.pig.tools.grunt.grunt-错误1200:pig脚本未能解析:表达式不是项目表达式:(名称:ScalarExpression)Type:null Uid:null)日志文件中的详细信息:/home/hduser/pig\u 141620106332.logits实际上是第4行,第32列:我编写了如下代码:A=使用PigStorage(“:”)作为(名称:chararray,单词:chararray)加载“pigex2”;grp=按名称划分的A组;result=foreach grp{filterbyword=FILTER grp by word MATCHES'.*bomb.*';生成组,计数(filterbyword.word);}将结果存储到'bombname'中;好的,我有问题了。而不是您在筛选器stmt中给出的“grp”。像这样更改代码。filterbyword=按与“.*bomb.*”匹配的单词筛选;
pras:1
sasi:2