Holds a variable shared among all workers that behaves like a local singleton.
Holds a variable shared among all workers that behaves like a local singleton. Useful to use non-serializable objects in Spark closures that maintain state across tasks.
Holds a variable shared among all workers.
Holds a variable shared among all workers. Useful to use non-serializable objects in Spark closures.
Note this code has been borrowed from: https://www.nicolaferraro.me/2016/02/22/using-non-serializable-objects-in-apache-spark/