val broadVar = env.fromCollection(List(Room("a", 11.2), Room("b", 22.3)))
val data = env.fromCollection(List("a", "b"))
val ds1 = data.map(new RichMapFunction[String, String] {
override def open(parameters: Configuration): Unit = {
val broadCast = getRuntimeContext.getBroadcastVariable[String]("roomBroadcast")
println(broadCast.size())
}
override def map(in: String): String = {in}
}).withBroadcastSet(broadVar, "roomBroadcast")
ds1.print()
data.map(new RichMapFunction[String, String] {
override def open(parameters: Configuration): Unit = {
val broadCast = getRuntimeContext.getBroadcastVariable[String]("roomBroadcast")
println(broadCast.size())
}
override def map(in: String): String = {in}
}).print()
在第一个算子里传递了广播变量后,在第二个算子没有传递,就不能复用使用之前广播好的变量吗?