[jira] [Created] (FLINK-970) Implement a first(n) operator

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (FLINK-970) Implement a first(n) operator

Shang Yuanchun (Jira)
Timo Walther created FLINK-970:
----------------------------------

             Summary: 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: Timo Walther
            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 | Threaded
Open this post in threaded view
|

Re: [jira] [Created] (FLINK-970) Implement a first(n) operator

Ufuk Celebi
+1

Spark also has the more general `take(n)` operation, of which first() is a special case. it might make sense to go for `take(n)` and just have first() as a special case.

On 24 Jun 2014, at 10:37, Timo Walther (JIRA) <[hidden email]> wrote:

> Timo Walther created FLINK-970:
> ----------------------------------
>
>             Summary: 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: Timo Walther
>            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)