当前位置:网站首页>(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.
边栏推荐
- [torch] some ideas to solve the problem that the tensor parameters have gradients and the weight is not updated
- 【Random Erasing】《Random Erasing Data Augmentation》
- win10解决IE浏览器安装不上的问题
- ModuleNotFoundError: No module named ‘pytest‘
- 【Cascade FPD】《Deep Convolutional Network Cascade for Facial Point Detection》
- Memory model of program
- yolov3训练自己的数据集(MMDetection)
- Using MATLAB to realize: power method, inverse power method (origin displacement)
- Comparison of chat Chinese corpus (attach links to various resources)
- 常见CNN网络创新点
猜你喜欢
半监督之mixmatch
Implementation of yolov5 single image detection based on onnxruntime
Deep learning classification Optimization Practice
机器学习理论学习:感知机
iOD及Detectron2搭建过程问题记录
ABM thesis translation
【Cascade FPD】《Deep Convolutional Network Cascade for Facial Point Detection》
[in depth learning series (8)]: principles of transform and actual combat
What if the notebook computer cannot run the CMD command
[multimodal] clip model
随机推荐
win10解决IE浏览器安装不上的问题
Win10 solves the problem that Internet Explorer cannot be installed
CONDA common commands
Win10+vs2017+denseflow compilation
【Mixup】《Mixup:Beyond Empirical Risk Minimization》
《Handwritten Mathematical Expression Recognition with Bidirectionally Trained Transformer》论文翻译
[mixup] mixup: Beyond Imperial Risk Minimization
[introduction to information retrieval] Chapter 1 Boolean retrieval
Two dimensional array de duplication in PHP
【TCDCN】《Facial landmark detection by deep multi-task learning》
【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization
程序的执行
Semi supervised mixpatch
Conversion of numerical amount into capital figures in PHP
【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
ABM thesis translation
[introduction to information retrieval] Chapter 7 scoring calculation in search system
Using compose to realize visible scrollbar
【Wing Loss】《Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks》
【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》