Question

ParMap (in Scala 2.9) doesn't seem to have a .values method. Why is this, and how can I work around it if I'm particularly keen on maintaining a parallel chain of processing such as the following?

myParSeq.collect{case i: Interesting => i}.groupBy(_.content).values. ...
Was it helpful?

Solution

Apparently an oversight.

Adding the missing ParMap and GenMap methods.

$ scala
Welcome to Scala version 2.10.0-RC2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_06).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import collection.parallel.immutable._
import collection.parallel.immutable._

scala> ParMap("a"->1)
res0: scala.collection.parallel.immutable.ParMap[String,Int] = ParMap(a -> 1)

scala> res0.values
res1: scala.collection.parallel.ParIterable[Int] = ParIterable(1)

How about:

$ scala29
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.

scala> Map("a"->1, "b"->2).par
res0: scala.collection.parallel.immutable.ParMap[java.lang.String,Int] = ParMap(a -> 1, b -> 2)

scala> .unzip._2
res1: scala.collection.parallel.immutable.ParIterable[Int] = ParVector(1, 2)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top