当前位置:网站首页>(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.
边栏推荐
- TimeCLR: A self-supervised contrastive learning framework for univariate time series representation
- Comparison of chat Chinese corpus (attach links to various resources)
- ModuleNotFoundError: No module named ‘pytest‘
- PHP returns the abbreviation of the month according to the numerical month
- Calculate the difference in days, months, and years between two dates in PHP
- Yolov3 trains its own data set (mmdetection)
- Win10 solves the problem that Internet Explorer cannot be installed
- 论文tips
- Jordan decomposition example of matrix
- 【Random Erasing】《Random Erasing Data Augmentation》
猜你喜欢
![[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

【Paper Reading】

机器学习理论学习:感知机

Drawing mechanism of view (I)

【Mixup】《Mixup:Beyond Empirical Risk Minimization》

【Mixed Pooling】《Mixed Pooling for Convolutional Neural Networks》

Mmdetection trains its own data set -- export coco format of cvat annotation file and related operations

【Mixup】《Mixup:Beyond Empirical Risk Minimization》

Proof and understanding of pointnet principle

【DIoU】《Distance-IoU Loss:Faster and Better Learning for Bounding Box Regression》
随机推荐
Optimization method: meaning of common mathematical symbols
Common CNN network innovations
win10+vs2017+denseflow编译
[introduction to information retrieval] Chapter 6 term weight and vector space model
Drawing mechanism of view (II)
聊天中文语料库对比(附上各资源链接)
What if the laptop can't search the wireless network signal
【Programming】
【TCDCN】《Facial landmark detection by deep multi-task learning》
How do vision transformer work?【论文解读】
[CVPR‘22 Oral2] TAN: Temporal Alignment Networks for Long-term Video
mmdetection训练自己的数据集--CVAT标注文件导出coco格式及相关操作
[Bert, gpt+kg research] collection of papers on the integration of Pretrain model with knowledge
【Mixup】《Mixup:Beyond Empirical Risk Minimization》
parser. parse_ Args boolean type resolves false to true
PPT的技巧
Yolov3 trains its own data set (mmdetection)
Generate random 6-bit invitation code in PHP
TimeCLR: A self-supervised contrastive learning framework for univariate time series representation
【DIoU】《Distance-IoU Loss:Faster and Better Learning for Bounding Box Regression》