summaryrefslogtreecommitdiff
path: root/test/pending/run/TestFlatMap.scala
blob: dd5a0a0c2f1201f34f0be4fc8bd19d3c922a0608 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import scala.collection.parallel.{ ParMap => PMap }
import scala.collection.parallel.mutable.{ ParHashSet => PMHashSet, ParHashMap => PMHashMap, ParArray }
import scala.util.Random
import scala.collection.parallel.CompositeThrowable

object Test {
  
  def main(args: Array[String]) {
    val N = 1500
    val M = 1500
    var unmatchedLeft = new PMHashSet[Int]
    var unmatchedRight = new PMHashSet[Int]
    Range(0, N).foreach{ x => unmatchedLeft += x}
    Range(0, M).foreach{ x => unmatchedRight += x}
    
    try {
      val matches = unmatchedLeft.flatMap{ lind: Int =>
        val dists = unmatchedRight.seq.map{ rind: Int =>
          val dist = Random.nextInt
          (rind, dist)
        }
        dists
      }
    } catch {
      case c: CompositeThrowable => for (t <- c.throwables) println("\n%s\n%s".format(t, t.getStackTrace.mkString("\n")))
    }
  }
  
}