First of all, you should pass an actual HashMap[String, String]
rather than (String, String)
:
sc.accumulator(HashMap("t" -> true))
And you may need to write your own accumulator, 'cause I didn't find an out-of-the-box implicit for the HashMap
:
implicit object iHashMap extends AccumulatorParam[HashMap[String, Boolean]] {
def zero(m: HashMap[String, String]) = HashMap()
def addInPlace(m1: HashMap[String, Boolean], m2: HashMap[String, Boolean]) = m1 ++ m2
}
The behaviour is probably not what you personally would expect, but I hope you catch the gist.
You may also find some really useful examples here: https://github.com/apache/spark/blob/60abc252545ec7a5d59957a32e764cd18f6c16b4/core/src/test/scala/org/apache/spark/AccumulatorSuite.scala