import org.apache.flink.api.scala._
import org.apache.flink.streaming.api.functions.co.CoMapFunction
import org.apache.flink.streaming.api.scala.{ConnectedStreams, DataStream, StreamExecutionEnvironment}
object JDBC {
def main(args: Array[String]): Unit = {
val senv: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
val intStream: DataStream[Int] = senv.fromElements(1, 0, 9, 2, 3, 6)
val stringStream: DataStream[String] = senv.fromElements("LOW", "HIGH", "LOW", "LOW")
val connectedStream: ConnectedStreams[Int, String] = intStream.connect(stringStream)
class MyCoMapFunction extends CoMapFunction[Int, String, String] {
override def map1(input1: Int): String = input1.toString
override def map2(input2: String): String = input2
}
val mapResult = connectedStream.map(new MyCoMapFunction)
mapResult.print()
senv.execute()
}
}
1> 1
8> LOW
2> LOW
4> 2
3> LOW
2> 0
6> 6
5> 3
1> HIGH
3> 9