Broadcast variables are read only shared objects which can be created with SparkContext.broadcast
method:
val broadcastVariable = sc.broadcast(Array(1, 2, 3))
and read using value
method:
val someRDD = sc.parallelize(Array(1, 2, 3, 4))
someRDD.map(
i => broadcastVariable.value.apply(i % broadcastVariable.value.size)
)