[ 
https://issues.apache.org/jira/browse/FLINK-970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14058693#comment-14058693
 ] 

Fabian Hueske commented on FLINK-970:
-------------------------------------

Sorry, I confused the use cases.

1) For the first n of each group, Stephan is of course right. Combine for the 
first n of each group in each partition and then reduce to the first n of each 
group in the Reducer.
2) For the first n of the whole data set, we can use a Map where each map 
(roughly) emits n / dop elements.

> Implement a first(n) operator
> -----------------------------
>
>                 Key: FLINK-970
>                 URL: https://issues.apache.org/jira/browse/FLINK-970
>             Project: Flink
>          Issue Type: New Feature
>            Reporter: Timo Walther
>            Assignee: Chesnay Schepler
>            Priority: Minor
>
> It is only syntactic sugar, but I had many cases where I just needed the 
> first element  or the first 2 elements in a GroupReduce.
> E.g. Instead of
> {code:java}
> .reduceGroup(new GroupReduceFunction<String, String>() {
>                                       @Override
>                                       public void reduce(Iterator<String> 
> values, Collector<String> out) throws Exception {
>                                               out.collect(values.next());
>                                       }
>                               })
> {code}
> {code:java}
> .first()
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to