Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Flink Union merge multiple data streams into a new data stream

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how Flink Union merges multiple data streams into a new data stream". The content in the article is simple and clear, and it is easy to learn and understand. please follow the editor's ideas to study and learn "how Flink Union merges multiple data streams into a new data stream".

Union operator: merges multiple data streams into a new data stream (data types must be consistent)

Sample environment,

Java.version: 1.8.xflink.version: 1.11.1

Sample data source (project code cloud download)

Building Development Environment and data of Flink system example

Union.java

Import com.flink.examples.DataSource;import org.apache.flink.api.java.tuple.Tuple3;import org.apache.flink.streaming.api.datastream.DataStream;import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;import java.util.List / * * @ Description Union operator: merge multiple data streams into a new data stream (data type must be consistent) * / public class Union {/ * traversal collection, merge multiple streams and print * @ param args * @ throws Exception * / public static void main (String [] args) throws Exception {final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment (); List tuple3List = DataSource.getTuple3ToList () / / Datastream 1 DataStream dataStream1 = env.fromCollection (tuple3List); / / Datastream 2 DataStream dataStream2 = env.fromCollection (tuple3List); / / Datastream 3 DataStream dataStream = dataStream1.union (dataStream2); dataStream.print (); env.execute ("flink Union job");}}

Print the result

3 > (Wang Wu, man,29) 2 > (Li Si, girl,24) 3 > (Wang Wu, man,29) 1 > (Zhang San, man,20) 1 > (Zhang San, man,20) 1 > (Wu Qi, girl,18) 1 > (Wu Qi, girl,18) 2 > (Wu Ba, man,30) 2 > (Li Si, girl,24) 2 > (Wu Ba, man,30) 4 > (Liu Liu, girl,32) 4 > (Liu Liu, girl,32) Thank you for reading The above is the content of "how Flink Union merges multiple data streams into a new data stream". After the study of this article, I believe you have a deeper understanding of how Flink Union merges multiple data streams into a new data stream, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report