[
https://issues.apache.org/jira/browse/PIG-741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704452#action_12704452
]
David Ciemiewicz commented on PIG-741:
--------------------------------------
Thanks Alan!
The fact that LIMIT in this case doesn't use the combiner is probably not an
issue. In most of the instances I have, I usually don't have more than a
million things in the grouped databag, most of the time I only have under 1000
to 10000 things so the combiner won't have much value.
> Add LIMIT as a statement that works in nested FOREACH
> -----------------------------------------------------
>
> Key: PIG-741
> URL: https://issues.apache.org/jira/browse/PIG-741
> Project: Pig
> Issue Type: New Feature
> Reporter: David Ciemiewicz
> Assignee: Alan Gates
> Fix For: 0.3.0
>
> Attachments: PIG-741.patch
>
>
> I'd like to compute the top 10 results in each group.
> The natural way to express this in Pig would be:
> {code}
> A = load '...' using PigStorage() as (
> date: int,
> count: int,
> url: chararray
> );
> B = group A by ( date );
> C = foreach B {
> D = order A by count desc;
> E = limit D 10;
> generate
> FLATTEN(E);
> };
> dump C;
> {code}
> Yeah, I could write a UDF / PiggyBank function to take the top n results. But
> since LIMIT already exists as a statement, it seems like it should also work
> in the nested foreach context.
> Example workaround code.
> {code}
> C = foreach B {
> D = order A by count desc;
> E = util.TOP(D, 10);
> generate
> FLATTEN(E);
> };
> dump C;
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.