apache pig-可以序列化变量吗?

y53ybaqx  于 2021-06-04  发布在  Hadoop
关注(0)|答案(2)|浏览(320)

让我们以wordcount为例:

input_lines = LOAD '/tmp/my-copy-of-all-pages-on-internet' AS (line:chararray);

-- Extract words from each line and put them into a pig bag
-- datatype, then flatten the bag to get one word on each row
bag_words = FOREACH input_lines GENERATE FLATTEN(TOKENIZE(line)) AS word;

是否可以序列化“bag\u words”变量,这样我们就不必每次执行脚本时都重新生成整个包?
谢谢。

mlnl4t2r

mlnl4t2r1#

您可以使用store命令在pig中输出任何别名:您可以使用标准格式(如csv)或编写自己的pigloader类来实现任何特定行为。然后可以在单独的脚本中加载此输出,从而绕过初始加载。

cmssoen2

cmssoen22#

STORE bag_words INTO 'some-output-directory'; 然后稍后阅读它,跳过foreach生成、展平、标记化。

相关问题