You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Zain Haider Nemati <za...@retailo.co> on 2022/05/13 07:29:01 UTC

Split string flatmap -> Arraylist/List

Hi,
I have a comma separated string of the format
x,y,z \n
a,b,c ...

I want to split the string on the basis of '\n' and insert each string into
the data stream separately using *flatmap*. Any example on how to do that?
If I add the chunks into an Arralist or List and return that from the
flatmap function would that work?

Re: Split string flatmap -> Arraylist/List

Posted by Alexander Preuß <al...@ververica.com>.
Hi Zain,

There are different options to achieve this. You can take a look at the
WordCount example [1] to get some inspiration.

[1]
https://github.com/apache/flink/blob/master/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/wordcount/WordCount.java

Best regards,
Alexander

On Fri, May 13, 2022 at 9:30 AM Zain Haider Nemati <za...@retailo.co>
wrote:

> Hi,
> I have a comma separated string of the format
> x,y,z \n
> a,b,c ...
>
> I want to split the string on the basis of '\n' and insert each string
> into the data stream separately using *flatmap*. Any example on how to do
> that? If I add the chunks into an Arralist or List and return that from the
> flatmap function would that work?
>


-- 

Alexander Preuß | Engineer - Data Intensive Systems

alexanderpreuss@ververica.com

<https://www.ververica.com/>


Follow us @VervericaData

--

Join Flink Forward <https://flink-forward.org/> - The Apache Flink
Conference

Stream Processing | Event Driven | Real Time

--

Ververica GmbH | Invalidenstrasse 115, 10115 Berlin, Germany

--

Ververica GmbH

Registered at Amtsgericht Charlottenburg: HRB 158244 B

Managing Directors: Karl Anton Wehner, Holger Temme, Yip Park Tung Jason,
Jinwei (Kevin) Zhang

Re: Split string flatmap -> Arraylist/List

Posted by Alexander Preuß <al...@ververica.com>.
Hi Zain,

There are different options to achieve this. You can take a look at the
WordCount example [1] to get some inspiration.

[1]
https://github.com/apache/flink/blob/master/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/wordcount/WordCount.java

Best regards,
Alexander

On Fri, May 13, 2022 at 9:30 AM Zain Haider Nemati <za...@retailo.co>
wrote:

> Hi,
> I have a comma separated string of the format
> x,y,z \n
> a,b,c ...
>
> I want to split the string on the basis of '\n' and insert each string
> into the data stream separately using *flatmap*. Any example on how to do
> that? If I add the chunks into an Arralist or List and return that from the
> flatmap function would that work?
>


-- 

Alexander Preuß | Engineer - Data Intensive Systems

alexanderpreuss@ververica.com

<https://www.ververica.com/>


Follow us @VervericaData

--

Join Flink Forward <https://flink-forward.org/> - The Apache Flink
Conference

Stream Processing | Event Driven | Real Time

--

Ververica GmbH | Invalidenstrasse 115, 10115 Berlin, Germany

--

Ververica GmbH

Registered at Amtsgericht Charlottenburg: HRB 158244 B

Managing Directors: Karl Anton Wehner, Holger Temme, Yip Park Tung Jason,
Jinwei (Kevin) Zhang