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

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

问题描述

我知道 Group 不能处理多个元组,因此我们在 PIG 中有 COGROUP.但是,今天检查时 GROUP 命令对我有用.我正在使用 PIG-0.12.0.我的命令和输出如下.

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)}}

GROUP 会像这样工作吗?GROUP 和 COGROUP 它们有什么区别?

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

推荐答案

是的,小组应该是这样工作的!

Yes group is supposed to work like that !

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

注意:GROUP 和 COGROUP 运算符是相同的.两个运营商与一个或多个关系合作.为了可读性,GROUP 用于涉及一种关系的语句,并且在语句中使用 COGROUP涉及两个或多个关系.您可以 COGROUP 最多但不能更多一次超过 127 个关系.

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.

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

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