Flink(五) —— DataStream API
2021-03-18 17:24
标签:reading collect one pac timestamp cal amp scala val Flink(五) —— DataStream API 标签:reading collect one pac timestamp cal amp scala val 原文地址:https://www.cnblogs.com/fonxian/p/12345930.htmlpackage flink
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
import org.apache.flink.api.scala._
case class SensorReading(id: String, timestamp: Long, temperature: Double)
object SourceTest {
def main(args: Array[String]): Unit = {
val env = StreamExecutionEnvironment.getExecutionEnvironment
// 1.从自定义的集合中读取数据
val list = List(
SensorReading("sensor1", 153242, 35.8),
SensorReading("sensor2", 153222, 15.4),
SensorReading("sensor3", 153142, 6.7),
SensorReading("sensor4", 151242, 38.7))
val stream1 = env.fromCollection(list)
stream1.print("stream1").setParallelism(1)
env.execute("source test")
}
}
文章标题:Flink(五) —— DataStream API
文章链接:http://soscw.com/index.php/essay/65864.html