当前位置:网站首页>Flink Learning 12: DataStreaming API
Flink Learning 12: DataStreaming API
2022-08-05 07:11:00 【hzp666】
1. Concept
2.DatStream programming
There are 3 parts that need to be implemented by code, 1. Data source 2. Conversion 3. Sink specified output format
2.1 Create environment
val env = ExecutionEnvironment.getExecutionEnvironment
The statement is relatively fixed
2.2 Data Source
There are three main built-in data sources:
2.2.1 Text Data Source
import org.apache.flink.streaming.api.scala._import org.apache.flink.streaming.api.scala.StreamExecutionEnvironmentobject readText {def main(args: Array[String]): Unit = {//create envval env = StreamExecutionEnvironment.getExecutionEnvironment//create datasourceval dataStream = env.readTextFile(filePath = "C:\\doc\\temp\\1. Introduction to the main line item.txt")//printdataStream.print()//executeenv.execute()}}
2.2.2 Socket Streams
Use the NC that comes with the Ubantu system to generate a socket data source
Then write code to monitor socket data
import org.apache.flink.api.scala._import org.apache.flink.streaming.api.scala.StreamExecutionEnvironmentobject socketSourceTest {def main(args: Array[String]): Unit = {//create envval env = StreamExecutionEnvironment.getExecutionEnvironment//create datasourceval socketDataStream = env.socketTextStream("localhost", 9999, '\n')//printsocketDataStream.print()//executeenv.execute()}}
Output results
2.2.3 Collection Data Sources
import org.apache.flink.api.scala._object CollectionSourceTest {def main(args: Array[String]): Unit = {//create envval env = ExecutionEnvironment.getExecutionEnvironment//collection data sourceval collectionDataStream = env.fromElements(Tuple1(1L, 2L), Tuple1(3L, 4L))//printcollectionDataStream.print()}}Output:
边栏推荐
- 《PyTorch深度学习实践》第十一课(卷积神经网络CNN高级版)
- 真实字节跳动测试开发面试题,拿下年薪50万offer。
- 共享内存+inotify机制实现多进程低延迟数据共享
- DNSlog外带数据注入
- Day9 of Hegong Daqiong team vision team training - camera calibration
- h5页面回退到微信小程序并携带参数
- After the firewall iptable rule is enabled, the system network becomes slow
- HR:这样的简历我只看了5秒就扔了,软件测试简历模板想要的进。
- 2022最强版应届生软件测试面试攻略
- Week 8 Document Clustering(文本聚类)
猜你喜欢
Bluetooth gap protocol
Shiny04---Application of DT and progress bar in shiny
TCP sticky packet unpacking problem + solution
IO process thread -> communication between processes -> day7
真实字节跳动测试开发面试题,拿下年薪50万offer。
原来使Maya Arnold也能渲染出高质量作品!超赞小技巧
2022杭电多校六 1006-Maex (树形DP)
合工大苍穹战队视觉组培训Day9——相机标定
Flink学习11:flink程序并行度
Shared memory + inotify mechanism to achieve multi-process low-latency data sharing
随机推荐
基于KECA-IGWO-KELM的间歇过程故障诊断方法
FPGA parsing B code----serial 4
【C语言】结构体变量数据通过 void* 传入到函数中
export使用
HR:这样的简历我只看了5秒就扔了,软件测试简历模板想要的进。
概率与期望部分题解
怎么样避免线上内存泄漏
技术分析模式(十一)如何交易头肩形态
Advanced Redis
武田公司2022财年第一季度业绩强劲;正稳步实现全年的管理层指引目标
蓝牙gap协议
原来使Maya Arnold也能渲染出高质量作品!超赞小技巧
Vulnhub靶机:HA_ NARAK
1, Citrix XenDesktop 2203 AD domain system installation (1)
[Tool Configuration] Summary of Common Uses of VSCode
2022熔化焊接与热切割操作证考试题及模拟考试
TCP的粘包拆包问题+解决方案
小程序input框不允许输入负数
Redis进阶
浮点数基础知识