ParMap 值方法替代



ParMap(在Scala 2.9中)似乎没有.values方法。 为什么会这样,如果我特别热衷于维护如下所示的并行处理链,我该如何解决它?

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

显然是一个疏忽。

添加缺少的 ParMap 和 GenMap 方法。

$ 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)

怎么样:

$ 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)

相关内容

  • 没有找到相关文章

最新更新