Flink--Split和select

Split就是将一个DataStream分成两个或者多个DataStream

Select就是获取分流后对应的数据

val env = StreamExecutionEnvironment.getExecutionEnvironment
env.setParallelism(1)
val elements: DataStream[Int] = env.fromElements(1,2,3,4,5,6)
//数据分流
val split_data = elements.split(
  (num: Int) => (num % 2) match {
    case 0 => List("even")
    case 1 => List("odd")
  }
)
//获取分流后的数据
val select: DataStream[Int] = split_data.select("even")
select.print()
env.execute()

 

posted @ 2018-05-22 20:13  niutao  阅读(324)  评论(0编辑  收藏  举报