当前位置:网站首页>11.1.2 overview of Flink_ Wordcount case
11.1.2 overview of Flink_ Wordcount case
2022-06-26 00:26:00 【Loves_ dccBigData】
WordCount Case study
flink The operator in is a stateful operator
— same key Be assigned to the same task in
— Note the error of implicit conversion
import org.apache.flink.streaming.api.scala._
object Demo01WordCount {
def main(args: Array[String]): Unit = {
// establish flink Environment
val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
/**
* Use nc To simulate streaming data
* yum install nc
* nc -lk 8888
*/
// Set parallelism , If it is not set , Different data are different task in ,12 Nuclear is 12 Before a number
// The data is divided into different cores to calculate the data
env.setParallelism(1)
// Read scoket The data of
val lineDS: DataStream[String] = env.socketTextStream("master", 8888)
// Take the data apart
val wordsDS: DataStream[String] = lineDS.flatMap(_.split(","))
// Set the number after the data to 1
val kvDS: DataStream[(String, Int)] = wordsDS.map((_, 1))
// Use KeyBy Grouping , Put different data in different places reduce task in
val keyByDS: KeyedStream[(String, Int), String] = kvDS.keyBy(_._1)
// Sum up , Sum the second element , Incoming subscript , Divide by subscript data , Subscript from 0 Start
// There are state operators
val countDS: DataStream[(String, Int)] = keyByDS.sum(1)
// Printout
countDS.print()
// start-up , Execution flow ,7*24 Perform the task in hours
env.execute()
}
}
边栏推荐
- Redis memory elimination mechanism
- What are the red lines of open source that should not be trodden on?
- 86. (cesium chapter) cesium overlay surface receiving shadow effect (gltf model)
- Farsync simple test
- SMT行业AOI,X-RAY,ICT分别是什么?作用是?
- SSL unresponsive in postman test
- Why do we need to make panels and edges in PCB production
- 10.4.1、數據中臺
- How ASA configures port mapping and pat
- SMT贴片加工PCBA板清洗注意事项
猜你喜欢

yolov5 提速多GPU训练显存低的问题

元宇宙中的法律与自我监管

leetcode.14 --- 最长公共前缀

被新冠后遗症困住15个月后,斯坦福学霸被迫缺席毕业典礼,现仍需每天卧床16小时:我本该享受20岁的人生啊...

The development context of Ba Kong Yuan universe industry

正则表达式介绍及一些语法

基于OpenVINOTM开发套件“无缝”部署PaddleNLP模型

Run the test program using rknn-toolkit-lite2 for rk3568 development board

About Simple Data Visualization

How to deliver a shelter hospital within 48 hours?
随机推荐
SMT操作员是做什么的?工作职责?
SQL中只要用到聚合函数就一定要用到group by 吗?
Display unassigned virtual address after easyconnect connection
Run the test program using rknn-toolkit-lite2 for rk3568 development board
Mysql5.7.31自定义安装详细说明
Detailed explanation of redis
leetcode.14 --- 最长公共前缀
How ASA configures port mapping and pat
Redux workflow + complete code of small examples
Datetimeformatter and localdatetime
Mysql5.7.31 user defined installation details
【TSP问题】基于Hopfield神经网络求解旅行商问题附Matlab代码
Setting up a cluster environment under Linux (2) -- installing MySQL under Linux
删库跑路、“投毒”、改协议,开源有哪几大红线千万不能踩?
Redis jump table
Regular expression introduction and some syntax
Comprehensive introduction to Simulink solver
SMT贴片加工pcba立碑现象的原因和解决方法
Idea set the template of mapper mapping file
Linux下搭建集群环境(2)-----------linux下安装Mysql