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

Stephan Ewen commented on FLINK-1098:
-------------------------------------

Another way to solve that would be to have a flatMapFunction that returns a 
collection.

{code}
text
    .flatMap( (line) -> Arrays.asList(line.toLowerCase().split("\\W+")) )
    .map( (word) -> new Tuple2(word, 1) )
    .groupBy(0)
    .sum(1);
{code}

> flatArray() operator that converts arrays to elements
> -----------------------------------------------------
>
>                 Key: FLINK-1098
>                 URL: https://issues.apache.org/jira/browse/FLINK-1098
>             Project: Flink
>          Issue Type: New Feature
>            Reporter: Timo Walther
>            Priority: Minor
>
> It would be great to have an operator that converts e.g. from String[] to 
> String. Actually, it is just a flatMap over the elements of an array.
> A typical use case is a WordCount where we then could write:
> {code}
> text
> .map((line) -> line.toLowerCase().split("\\W+"))
> .flatArray()
> .map((word) -> new Tuple2(word, 1))
> .groupBy(0)
> .sum(1);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to