将使用累加器的最短 Pig 脚本

Shortest Pig script that will use Accumulator

我正在向 Pig UDF 添加一个累加器实现,我想测试它。

使用累加器的最短最简单的 Pig 脚本是什么?

为简单起见,假设它将加载一个包含 N 个整数的文件,其中 N > pig.accumulative.batchsize 这样accumulate()方法就会被调用不止一次。

data = LOAD 'input' AS (val1:int);

output = ... (code which uses the UDF comes here)

STORE output INTO 'output';

看来这样就够了:

data = LOAD 'input' AS (val1:int);

output = FOREACH (group d all) GENERATE ACCUMULATIVE_UDF(val1);

STORE output INTO 'output';