GROUP和COGROUP在PIG上有什么区别? [英] What is the difference between GROUP and COGROUP in PIG?

查看:165
本文介绍了GROUP和COGROUP在PIG上有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Group没有使用多个元组,因此我们在PIG中使用了COGROUP。然而,在今天检查时,GROUP命令适用于我。我正在使用PIG-0.12.0。
我的命令和输出如下。

  grunt> grpvar = GROUP C减$ 2,B减$ 2; 
grunt> cogrpvar = COGROUP C减$ 2,B减$ 2;
grunt>描述grpvar;

grpvar {group:chararray,C:{(pid:int,pname:chararray,drug:chararray,gender:chararray,tot_amt:int)},B:{(pid:int,pname :chararray,drug:chararray,性别:chararray,tot_amt:int)}}

grunt>描述cogrpvar;

cogrpvar:{group:chararray,C:{(pid:int,pname:chararray,drug:chararray,gender:chararray,tot_amt:int)},B:{(pid:int,pname :chararray,drug:chararray,性别:chararray,tot_amt:int)}}

像这样工作?
GROUP和COGROUP有什么不同?

解决方案

是的团队应该像这样工作! p>

根据文档( http:// pig.apache.org/docs/r0.12.0/basic.html#group ):


注意:GROUP和COGROUP运营商是相同的。两个运营商
都有一个或多个关系。为了便于阅读,GROUP用于涉及一个关系的
语句,而COGROUP用于涉及两个或多个关系的
语句。您可以一次购买多达
但不超过
的交易。


所以它只是为了可读性,不可以两者之间的差异。

I understood Group didn't work with multiple tuples and hence we had COGROUP in PIG. However, while checking today the GROUP command works for me. I am using PIG-0.12.0. My commands and outputs are as follows.

grunt> grpvar = GROUP C by $2, B by $2;
grunt> cogrpvar = COGROUP C by $2, B by $2;
grunt> describe grpvar;

grpvar: {group: chararray,C: {(pid: int,pname: chararray,drug: chararray,gender: chararray,tot_amt: int)},B: {(pid: int,pname: chararray,drug: chararray,gender: chararray,tot_amt: int)}}

grunt> describe cogrpvar;

cogrpvar: {group: chararray,C: {(pid: int,pname: chararray,drug: chararray,gender: chararray,tot_amt: int)},B: {(pid: int,pname: chararray,drug: chararray,gender: chararray,tot_amt: int)}}

Is GROUP expected to work like this? What is the difference between GROUP and COGROUP them?

解决方案

Yes group is supposed to work like that !

According to the documentation ( http://pig.apache.org/docs/r0.12.0/basic.html#group ) :

Note: The GROUP and COGROUP operators are identical. Both operators work with one or more relations. For readability GROUP is used in statements involving one relation and COGROUP is used in statements involving two or more relations. You can COGROUP up to but no more than 127 relations at a time.

So it is just for readability, no differences between the two.

这篇关于GROUP和COGROUP在PIG上有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆