Github user viirya commented on the pull request:
https://github.com/apache/spark/pull/5572#issuecomment-94170894
Run the following codes to test the performance:
def randomString() = {
def randChar = 'A' + (math.random * 4).toInt
val length = 1000
(1 to length).map(i => randChar).mkString
}
def similarity(x : (Long, String), y : (Long, String)) = {
val pairs = (x._2.toList) zip (y._2.toList)
pairs.count{case (c1, c2) => c1 == c2}.toDouble / pairs.length
}
def time[A](f: => A) = {
val start = System.nanoTime
f
(System.nanoTime-start)/1e6
}
val ids = sc.parallelize(1L to 10L).repartition(16)
val data = ids.map{id => (id, randomString())}.cache()
val pairs = data.cartesian(data).filter { case (x,y) => similarity(x,
y) > 0.3}
time { val hits = pairs.count }
old: 212.76s
new: 3.77s
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]