当前位置:网站首页>Flink's sink: a preliminary study
Flink's sink: a preliminary study
2020-11-08 16:12:00 【Programmer Xinchen】
Welcome to visit mine GitHub
https://github.com/zq2599/blog_demos
Content : All original articles classified summary and supporting source code , involve Java、Docker、Kubernetes、DevOPS etc. ;
About sink
The following figure comes from Flink official , In the red box is sink, Visible real-time data from Source Start at , stay Transformation After the business logic is completed in sink end , therefore sink It can be used to process the calculation results , For example, console output or save database :
About 《Flink Of sink actual combat 》 Series articles
This article is about 《Flink Of sink actual combat 》 The first chapter of , In order to have a preliminary understanding of sink, Through the basic API and addSink Method analysis and research , Lay a good foundation for the subsequent coding practice ;
Full series Links
- 《Flink Of sink One of the real battles : On 》
- 《Flink Of sink The second part of the actual battle :kafka》
- 《Flink Of sink The third part of the actual battle :cassandra3》
- 《Flink Of sink The fourth part of the actual battle : Customize 》
Start with an instance code
- Here is a simple flink Application code , The red box print The way is sink operation :
- Here's the official sink The way , All are DataStream Class API, It can be directly called sink, Just in the code print It's one of them :
- Let's look at the picture above API Source code , First look at print Method , stay DataStream.java in , as follows , It's actually called addSink Method , Participation is PrintSinkFunction:
- The other is often used API yes writeAsText, Source code is as follows , Called writeUsingOutputFormat Method :
- track <font color="blue">writeUsingOutputFormat</font> Discovery is also called addSink, Participation is <font color="blue">OutputFormatSinkFunction</font>:
- print and writeAsText Behind the call addSink, So another common <font color="blue">writeAsCsv</font> Methods? ? It's a call addSink? Open it and see , and writeAsText Same call <font color="blue">writeUsingOutputFormat</font>, In this method, you are calling addSink:
- in summary ,data sink The key is <font color="blue">addSink</font> Input , namely <font color="blue">SinkFunction</font> Interface implementation , Use class diagrams to visualize common sink How is ability realized :
8. From the figure above, we can see the abstract class <font color="blue">RichSinkFunction</font> With all kinds of sink Ability is closely related , We should focus on it , Show method signature on class diagram , Here's the picture : 9. As shown in the figure above ,<font color="blue">RichSinkFunction</font> There is no content in itself , But it does <font color="blue">SinkFunction</font>, Inherit <font color="blue">AbstractRichFunction</font>, yes <font color="blue">RichFunction</font> and <font color="blue">SinkFunction</font> The combination of these two characteristics ; 10. <font color="blue">RichFunction</font> The characteristics of are in front of 《Flink Of DataSource Trilogy 》 We already know , It's about resources open and close; 11. <font color="blue">SinkFunction</font> The characteristics of ? It's obviously used to process the calculation results , The class diagram shows two invoke Method , Take a look at the official <font color="blue">PrintSinkFunction.java</font>: 12. <font color="blue">writer.write(record)</font> The source code is PrintSinkOutputWriter.java, As shown below :
Summary
thus , We're right Flink Of sink With a basic understanding :
- Be responsible for the processing of real-time calculation results ( Like output or persistence );
- The main implementation is to call DataStream.addSink Method ;
- Various sink The realization of ability , The main way is to achieve addSink The interface defined by the input parameter of the method ;
Later chapters , Together with sink Let's practice the coding of the aspect , The direction of actual combat : Experience the official sink Ability , Customize sink Ability to achieve ;
Welcome to the official account : Xinchen, programmer
WeChat search 「 Xinchen, programmer 」, I'm Xinchen , Looking forward to traveling with you Java The world ... https://github.com/zq2599/blog_demos
版权声明
本文为[Programmer Xinchen]所创,转载请带上原文链接,感谢
边栏推荐
- Solution of DEV-C + + unable to debug in Windows Environment
- We made a medical version of the MNIST dataset, and found that the common automl algorithm is not so easy to use
- wanxin finance
- RestfulApi 学习笔记——父子资源(四)
- AI周报:允许“员工自愿降薪”;公司回应:员工内心高兴满意;虎牙HR将员工抬出公司;瑞典禁用华为中兴5G设备
- 喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水
- How to make a correct summary for 7 years?
- API生命周期的5个阶段
- Learn to record and analyze
- AI weekly: employees are allowed to voluntarily reduce salary; company response: employees are happy and satisfied; tiger tooth HR takes employees out of the company; Sweden forbids Huawei ZTE 5g equi
猜你喜欢
Leancloud changes in October
Tips and skills of CSP examination
write文件一个字节后何时发起写磁盘IO
契约式设计(Dbc)以及其在C语言中的应用
C++的那些事儿:从电饭煲到火箭,C++无处不在
[Python 1-6] Python tutorial 1 -- number
2035 we will build such a country
喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水
wanxin finance
The first open source Chinese Bert pre training model in the financial field
随机推荐
这几个C++的坑,一旦踩中了,加班是肯定避免不了了!
佛萨奇forsage以太坊智能合约是什么?以太坊全球滑落是怎么回事
阿里云视频云技术专家 LVS 演讲全文:《“云端一体”的智能媒体生产制作演进之路》
Builder pattern
Framework - SPI four modes + general device driver implementation - source code
10个常见的软件架构模式
Blockchain weekly: the development of digital currency is written into the 14th five year plan; Biden invited senior adviser of MIT digital currency program to join the presidential transition team; V
On the concurrency of update operation
C + + things: from rice cookers to rockets, C + + is everywhere
基于阿里云日志服务快速打造简版业务监控看板
Improvement of maintenance mode of laravel8 update
How to solve the difference between NAT IP and port IP
wanxin finance
2020-11-05
read文件一个字节实际会发生多大的磁盘IO?
Using k3s to create local development cluster
总结: 10月海外DeFi新项目,更多资管策略来了!
模板引擎的整理归纳
重返全球第三,小米做对了什么?
Flink from introduction to Zhenxiang (7. Sink data output file)