I’m trying to do a simple aggregation in a collection I’ve grouped. Like this:
case class Foo(key:String, value:Int)
val minPerKey = lotsOfFoos.groupBy(_.key).mapValues(_.minBy(_.value))
Now I want to do the same in parallel but ParMap doesn’t have a mapValues function.
Why is this so, and how should I do it alternatively?
Scala 2.10 has mapValues for ParMap.
But there isn’t a whole lot of benefit to using mapValues with a ParMap. The mapValues method just gives you a new Map that applies your function when reading values, it doesn’t actually change the values in the Map. So you would need to do some other action that would force the creation of a new Map with the mapped values.