You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2023/05/30 14:42:57 UTC

[GitHub] [spark] LuciferYang commented on a diff in pull request #41384: [SPARK-43297][ML]Use scala parallel collection ParVector to accelarate LocalKMeans.

LuciferYang commented on code in PR #41384:
URL: https://github.com/apache/spark/pull/41384#discussion_r1210393260


##########
mllib/src/main/scala/org/apache/spark/mllib/clustering/LocalKMeans.scala:
##########
@@ -46,7 +47,9 @@ private[mllib] object LocalKMeans extends Logging {
 
     // Initialize centers by sampling using the k-means++ procedure.
     centers(0) = pickWeighted(rand, points, weights).toDense
-    val costArray = points.map(EuclideanDistanceMeasure.fastSquaredDistance(_, centers(0)))
+    val pointsParVector = new ParVector(points.toVector)

Review Comment:
   Can you find the threshold for `points.length` that can get performance improvement?
   
   Not sure this always can get performance improvement, `points.toVector` will also be some costs,  it will create a new Vector and add all elements using tail recursion.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org