File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
mllib/src/main/scala/org/apache/spark/mllib/clustering Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,8 @@ class KMeans private (
301301 contribs.iterator
302302 }.reduceByKey(mergeContribs).collectAsMap()
303303
304+ bcActiveCenters.unpersist(blocking = false )
305+
304306 // Update the cluster centers and costs for each active run
305307 for ((run, i) <- activeRuns.zipWithIndex) {
306308 var changed = false
@@ -419,7 +421,10 @@ class KMeans private (
419421 s0
420422 }
421423 )
424+
425+ bcNewCenters.unpersist(blocking = false )
422426 preCosts.unpersist(blocking = false )
427+
423428 val chosen = data.zip(costs).mapPartitionsWithIndex { (index, pointsWithCosts) =>
424429 val rand = new XORShiftRandom (seed ^ (step << 16 ) ^ index)
425430 pointsWithCosts.flatMap { case (p, c) =>
@@ -448,6 +453,9 @@ class KMeans private (
448453 ((r, KMeans .findClosest(bcCenters.value(r), p)._1), 1.0 )
449454 }
450455 }.reduceByKey(_ + _).collectAsMap()
456+
457+ bcCenters.unpersist(blocking = false )
458+
451459 val finalCenters = (0 until runs).par.map { r =>
452460 val myCenters = centers(r).toArray
453461 val myWeights = (0 until myCenters.length).map(i => weightMap.getOrElse((r, i), 0.0 )).toArray
You can’t perform that action at this time.
0 commit comments