2024-1-24
广播变量特点
? ? ??
object BroadcastTest {
def main(args: Array[String]): Unit = {
val conf: SparkConf = new SparkConf().setAppName("Broadcast").setMaster("local")
val sc = new SparkContext(conf)
sc.setLogLevel("ERROR")
val listRDD: RDD[Int] = sc.parallelize(List(1, 2, 3, 4))
var num = 2
val bc: Broadcast[Int] = sc.broadcast(num)
listRDD.map(x=> x * bc.value).foreach(println)
}
}