2012-12-14 149 views
1

ParMap(在Scala 2.9中)似乎没有.values方法。为什么会这样,如果我特别热衷于维护并行处理链,如何能够解决这个问题?ParMap方法替代方法

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

你为什么不能代替'.values'用'.MAP(_._ 2)'? –

+0

虽然没有,会做。只是感到惊讶,它不在那里。 – Pengin

回答

2

显然是疏忽。

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) 

如何:

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