A = LOAD 'test.txt' AS (a1:chararray, a2:int);
B = FOREACH A GENERATE ToDate(a1, 'y-M-d', 'UTC') as date, a2;
C = FOREACH B GENERATE AddDuration(date, 'P1D') as nextdate, -a2 as a2;
D = join B by date, C by nextdate;
E = FOREACH D GENERATE B::date as date, B::a2 + C::a2 as value;
dump E;
1条答案
按热度按时间jk9hmnmh1#
在hadoop中,引用上一条记录是很困难的,因为我们将输入分割并分配给不同的任务。我认为下面的方法可行,但效率很低(与按顺序读取数据的单个进程相比)。