I want to use a broadcast variable in Spark with Scala. But I can't find enough help on how to use them. Say, I have an object of class A, which I normally would declare as follows in Scala.
val a = new A()
What would be the syntax of declaring it as a broadcast variable. And how would I call its methods?
If
sc
is aSparkContext
, thenval broadcasted = sc.broadcast(a)
will broadcasta
.You can then access it with
broadcasted.value
.