In Spark program ,I WANT To define a variable like immutable map which will be accessed by all worker programs synchrononously, what can I do ? Should I define an scala object?
Not only immutable map , what if I want a variable that can be shared and can be updated synchronously? For example , a 'mutable map' , a 'var Int' or 'var String' or some others?What can I do? Is an scala object variable OK?For example :
Object SparkObj{
var x:Int
var y:String
}
- Is x and y maintained by driver instead of worker and shared by all workers?
Is x and y have only one copy instead of several copies?
Is the update to x and y synchronous?