I have a singleton object Main, and defined private var
private var params: Broadcast[Parameters] = _
Then I am initializing it through the main method
def main(args: Array[String]) = {
...
params = spark.sparkContext.broadcast(new Parameters())
I have a method inside this object, then pass rdd argument and trying to get a value from broadcast variable in map transformation.
def testMethod(rdd: RDD[String]): Unit = {
rdd.map(elem -> {
val currentDate = params.value.CURRENT_DATE
...
Got an error on line where I try to get value grom params: NullPointerException. How to fix this code to make it work? I can't understand what is wrong with initialization.