Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hadoop 在PIG拉丁语中,展平运算符的用途是什么_Hadoop_Apache Pig - Fatal编程技术网

Hadoop 在PIG拉丁语中,展平运算符的用途是什么

Hadoop 在PIG拉丁语中,展平运算符的用途是什么,hadoop,apache-pig,Hadoop,Apache Pig,A=加载“数据”为x,y B=加载“数据”为x,z C=A乘x的同组,B乘x的同组 D=每个C生成扁平化A,扁平化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) -->

A=加载“数据”为x,y

B=加载“数据”为x,z

C=A乘x的同组,B乘x的同组

D=每个C生成扁平化A,扁平化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

在下面的答案中解释得很好,扁平化是可以的,但我也希望上面的陈述是示例,您所说的示例是什么意思?以上就是一个例子。如果你的意思是详细的描述,请查看pig docs@Arun我正在询问的填充数据,如x,y->1,2 1,3 2,3,x,z->1,4 1,2 3,2…,等等