flink source fromCollection source

import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}
import org.apache.flink.api.scala._

object FlinkDemo03_CommonSource_fromEle {
    
    case class Student(name: String, age: Int)
    
    def main(args: Array[String]): Unit = {
        //1 创建环境
        val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
        //2 读取数据
        val ds: DataStream[Student] = env.fromCollection(List(Student("jack", 20), Student("rose", 18)))
        //3 计算
        ds.print()
        
        //4 执行
        env.execute()
    }
}

 

posted on 2020-06-22 01:15  天天背单词  阅读(842)  评论(0编辑  收藏  举报

导航