当前位置:网站首页>(15) Flick custom source
(15) Flick custom source
2022-07-02 07:48:00 【wx5ba7ab4695f27】
List of articles
source
package com.htsec.test
import org.apache.flink.streaming.api.functions.source.SourceFunction
import scala.util.Random
class MySource() extends SourceFunction[SersorReading] {
//flag Indicates whether the data source is running normally
var running: Boolean = true
override def run(ctx: SourceFunction.SourceContext[SersorReading]): Unit = {
// Initialize a random number generator
val random = new Random()
// Random generation 10 Initial temperature value of sensors , And sensors id Form a binary
var curTemp = 1.to(10).map(
i => ("sensor_" + i, random.nextGaussian() * 20 + 60)
)
while (running) {
// Update based on last temperature value
curTemp.map(
data => (data._1, data._2 + random.nextGaussian())
)
// Get the current timestamp
val curTime = System.currentTimeMillis()
curTemp.foreach(
data => ctx.collect(SersorReading(data._1,curTime,data._2))
)
}
}
override def cancel(): Unit = {
running = false
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
The main class
package com.htsec.test
import org.apache.flink.streaming.api.scala._
case class SersorReading(id: String,timeStamp:Long,temperature : Double)
object SourceTest {
def main(args: Array[String]): Unit = {
val env = StreamExecutionEnvironment.getExecutionEnvironment
val lines = env.addSource(new MySource)
lines.print()
env.execute()
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
边栏推荐
- ABM thesis translation
- [mixup] mixup: Beyond Imperial Risk Minimization
- Translation of the paper "written mathematical expression recognition with bidirectionally trained transformer"
- Win10 solves the problem that Internet Explorer cannot be installed
- How to turn on night mode on laptop
- 论文tips
- win10+vs2017+denseflow编译
- 【Programming】
- 【FastDepth】《FastDepth:Fast Monocular Depth Estimation on Embedded Systems》
- [CVPR‘22 Oral2] TAN: Temporal Alignment Networks for Long-term Video
猜你喜欢

How to turn on night mode on laptop

ModuleNotFoundError: No module named ‘pytest‘

MoCO ——Momentum Contrast for Unsupervised Visual Representation Learning

PointNet原理证明与理解

label propagation 标签传播
![[introduction to information retrieval] Chapter 7 scoring calculation in search system](/img/cc/a5437cd36956e4c239889114b783c4.png)
[introduction to information retrieval] Chapter 7 scoring calculation in search system

Faster-ILOD、maskrcnn_benchmark训练coco数据集及问题汇总

Use Baidu network disk to upload data to the server

Implementation of yolov5 single image detection based on pytorch

Semi supervised mixpatch
随机推荐
Latex formula normal and italic
【Cutout】《Improved Regularization of Convolutional Neural Networks with Cutout》
Use Baidu network disk to upload data to the server
【FastDepth】《FastDepth:Fast Monocular Depth Estimation on Embedded Systems》
win10解决IE浏览器安装不上的问题
【深度学习系列(八)】:Transoform原理及实战之原理篇
【DIoU】《Distance-IoU Loss:Faster and Better Learning for Bounding Box Regression》
Optimization method: meaning of common mathematical symbols
What if the laptop task manager is gray and unavailable
CPU register
How to turn on night mode on laptop
超时停靠视频生成
Common machine learning related evaluation indicators
[introduction to information retrieval] Chapter 3 fault tolerant retrieval
Memory model of program
Thesis writing tip2
[medical] participants to medical ontologies: Content Selection for Clinical Abstract Summarization
Implement interface Iterable & lt; T>
常见的机器学习相关评价指标
【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》