Broadcast广播变量的使用规则:
1.可以使用SparkContext.broadcast([初始值])创建
2.使用 .value的方法来读取广播变量的值
3.Broadcast广播变量被创建后不能修改
broadcast方法
def broadcast(self, value):
"""
Broadcast a read-only variable to the cluster, returning a
L{Broadcast<pyspark.broadcast.Broadcast>}
object for reading it in distributed functions. The variable will
be sent to each cluster only once.
"""
return Broadcast(self, value, self._pickled_broadcast_vars)
broadcast用法
broadcast(value)
Broadcast a read-only variable to the cluster, returning a L{Broadcast<pyspark.broadcast.Broadcast>} object for reading it in distributed functions. The variable will be sent to each cluster only once.