HashMap as a Broadcast Variable in Spark Streaming?
In spark you can broadcast any serializable object the same way. This is the best way because you are shipping data only once to the worker and then you can use it in any of the tasks.
Scala:
val br = ssc.sparkContext.broadcast(Map(1 -> 2))
Java:
Broadcast<HashMap<String, String>> br = ssc.sparkContext().broadcast(new HashMap<>());