package com.kpwong.aiptest
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}
import org.apache.flink.api.scala._
object SourceTest {
def main(args: Array[String]): Unit = {
val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
//1: 从集合中读取数据
val datalist = List(
SensorReading("sensor_1", 1547718199, 35.8),
SensorReading("sensor_6", 1547718201, 15.4),
SensorReading("sensor_7", 1547718202, 6.7),
SensorReading("sensor_10", 1547718205, 38.1)
)
val streamDS: DataStream[SensorReading] = env.fromCollection(datalist)
streamDS.print()
env.execute()
}
}
//定义伴生类
case class SensorReading(id:String,timestamp:Long, temperature:Double)