1

我有两套

personCounts 
(personName:chararray, count:int)

whitelist
(empID:int, empName:chararray)

我想要的是在 personCounts 中但不在白名单中的人。我知道 JOIN 返回出现在两者中的元素。有没有办法返回那些会被丢弃的东西?我在想我可以用 CROSS 做到这一点,但我想我会有额外的东西..?

crossed = CROSS personCounts BY personName, whitelist BY empName;
filcrs = FILTER crossed BY NOT personCounts::personName MATCHES whitelist::empName;
4

2 回答 2

2

我认为您想要实现的是 personCounts 和白名单之间的设置差异是否正确?

如果是这样,请尝试以下方法(未经测试!!!):

CGRP = COGROUP personCounts BY personName, whitelist BY empName;
PC_MINUS_WL = FILTER CGRP BY IsEmpty(whitelist);
PC_MINUS_WL = FOREACH PC_MINUS_WL GENERATE group AS name;

我发现以下两个资源很有帮助:

http://agiletesting.blogspot.de/2012/02/set-operations-in-apache-pig.html

http://www.cs.tufts.edu/comp/150CPA/notes/Advanced_Pig.pdf

于 2013-04-03T16:53:38.607 回答
2

您可以使用 JOIN FULL 来做到这一点。

joined = JOIN personCounts BY personName FULL, whitetlist BY empName;
joined = FILTER joined BY NOT $0 MATCHES '';
joined = FILTER joined BY $3 IS null;

然后加入的是 (personName, count, , '')

于 2013-04-03T18:05:41.353 回答