srowen commented on a change in pull request #27052: [SPARK-30390][MLLIB] Avoid 
double caching in mllib.KMeans#runWithWeights.
URL: https://github.com/apache/spark/pull/27052#discussion_r362234083
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/mllib/clustering/KMeans.scala
 ##########
 @@ -232,7 +232,10 @@ class KMeans private (
     val zippedData = data.zip(norms).map { case ((v, w), norm) =>
       (new VectorWithNorm(v, norm), w)
     }
-    zippedData.persist(StorageLevel.MEMORY_AND_DISK)
+
+    if (data.getStorageLevel == StorageLevel.NONE) {
+      zippedData.persist(StorageLevel.MEMORY_AND_DISK)
+    }
 
 Review comment:
   Yeah I thought that was your point. If zippedData were expensive, I'd agree 
that caching the intermediate values too is worthwhile, and we do that in some 
places. Here it's not, and the original behavior was to always cache 
internally, so I guess this is less of a change. This at least skips it where 
it can be inexpensively computed

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to