gpt4 book ai didi

hadoop - PIG Latin 中 FLATTEN 运算符的用途是什么

转载 作者:可可西里 更新时间:2023-11-01 16:21:58 30 4
gpt4 key购买 nike

A = 将“数据”加载为 (x, y);

B = 将“数据”加载为 (x, z);

C = cogroup A by x, B by x;

D = foreach C 生成 flatten(A), flatten(b);

E = A::x 组 D

在上面的语句中到底做了什么以及我们在实时场景中使用了展平的地方。

最佳答案

A = load 'input1'   USING PigStorage(',') as (x, y);
(x,y) --> (1,2)(1,3)(2,3)
B = load 'input2' USING PigStorage(',') as (x, z);`
(x,z) --> (1,4)(1,2)(3,2)*/
C = cogroup A by x, B by x;`

result:

(1,{(1,2),(1,3)},{(1,4),(1,2)})
(2,{(2,3)},{})
(3,{},{(3,2)})


D = foreach C generate group, flatten(A), flatten(B);`

when both bags flattened, the cross product of tuples are returned.

result:
(1,1,2,1,4)
(1,1,2,1,2)
(1,1,3,1,4)
(1,1,3,1,2)

E = group D by A::x`

here your are grouping with x column of relation A.

(1,1,2,1,4) (1,1,2,1,2) (1,1,3,1,4) (1,1,3,1,2)

关于hadoop - PIG Latin 中 FLATTEN 运算符的用途是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28472179/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com