Flink(五) —— DataStream API

2021-03-18 17:24

阅读:427

标签:reading   collect   one   pac   timestamp   cal   amp   scala   val   

package 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

标签:reading   collect   one   pac   timestamp   cal   amp   scala   val   

原文地址:https://www.cnblogs.com/fonxian/p/12345930.html


评论


亲,登录后才可以留言!