【发布时间】:2016-09-07 18:50:46
【问题描述】:
抱歉,问题的措辞有误。 我是 stackoverflow 的新手,也是 PIG 的新手,我正在尝试自己进行实验。
我有一个处理 words.t 文件和 data.txt 文件的场景。
words.txt
word1
word2
word3
word4
数据.txt
{"created_at":"18:47:31,Sun Sep 30 2012","text":"RT @Joey7Barton: ..give a word1 about whether the americans wins a Ryder cup. I mean surely he has slightly more important matters. #fami ...","user_id":450990391,"id":252479809098223616}
我需要得到输出
(word1_epochtime){与文本属性匹配的完整数据}
即
(word1_1234567890){"created_at":"18:47:31,Sun Sep 30 2012","text":"RT @Joey7Barton: ..give a word1 about whether the americans wins a Ryder cup. I mean surely he has slightly more important matters. #fami ...","user_id":450990391,"id":252479809098223616}
我得到了输出
(word1){"created_at":"18:47:31,Sun Sep 30 2012","text":"RT @Joey7Barton: ..give a word1 关于美国人是否赢得莱德杯。我的意思是肯定他 有稍微重要的事情。 #家庭 ...","user_id":450990391,"id":252479809098223616}
通过使用此脚本。
load words.txt
load data.txt
c = cross words,data;
d = FILTER c BY (data::text MATCHES CONCAT(CONCAT('.*',words::word),'.*'));
e = foreach (group d BY word) {data);
我得到了带有单词的纪元
time = FOREACH words GENERATE CONCAT(CONCAT(word,'_'),(chararray)ToUnixTime(CurrentTime(created_at));
但我无法将单词与时间联系起来。
我怎样才能得到输出
(word1_time){data}
请随时向我提出上述建议。 谢谢。
【问题讨论】:
标签: hadoop apache-pig epoch