我是新来的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
它是每个名字出现“bomb”的次数(sasi,pras)。
**Code:**
**A = load 'bomb' USING PigStorage(':') as (name:chararray,word:chararray);
B = FOREACH A generate(flatten(word)) as words;
C = FILTER B by words == 'bomb';**
d = group C by A.name;
i am confused from step 'd' ,can anyone say how to acheive the above mentioned output like
sasi:2
pras:1
Thanks in advance.
1条答案
按热度按时间ohtdti5x1#
像这样试试
输出: