From 4e0d26653f3828219a7ac0b053f11faa44d6cdb1 Mon Sep 17 00:00:00 2001 From: Zheng RuiFeng Date: Tue, 19 Dec 2017 17:33:49 +0800 Subject: [PATCH 1/3] create pr --- .../org/apache/spark/mllib/clustering/BisectingKMeans.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala b/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala index ae98e24a75681..42dcd8288c0d6 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala @@ -197,7 +197,7 @@ class BisectingKMeans private ( newClusters = summarize(d, newAssignments) newClusterCenters = newClusters.mapValues(_.center).map(identity) } - if (preIndices != null) preIndices.unpersist() + if (preIndices != null) preIndices.unpersist(blocking = false) preIndices = indices indices = updateAssignments(assignments, divisibleIndices, newClusterCenters).keys .persist(StorageLevel.MEMORY_AND_DISK) @@ -212,7 +212,9 @@ class BisectingKMeans private ( } level += 1 } - if(indices != null) indices.unpersist() + if (preIndices != null) preIndices.unpersist(blocking = false) + if(indices != null) indices.unpersist(blocking = false) + norms.unpersist(blocking = false) val clusters = activeClusters ++ inactiveClusters val root = buildTree(clusters) new BisectingKMeansModel(root) From e05cc267d9246e6ba662bfb882bfb5864600fb2b Mon Sep 17 00:00:00 2001 From: Zheng RuiFeng Date: Tue, 19 Dec 2017 17:47:18 +0800 Subject: [PATCH 2/3] lint --- .../org/apache/spark/mllib/clustering/BisectingKMeans.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala b/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala index 42dcd8288c0d6..bc29ad8a26c5f 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala @@ -213,7 +213,7 @@ class BisectingKMeans private ( level += 1 } if (preIndices != null) preIndices.unpersist(blocking = false) - if(indices != null) indices.unpersist(blocking = false) + if (indices != null) indices.unpersist(blocking = false) norms.unpersist(blocking = false) val clusters = activeClusters ++ inactiveClusters val root = buildTree(clusters) From 3767e805a981a0442378e110e1049b5e0efa6a54 Mon Sep 17 00:00:00 2001 From: Zheng RuiFeng Date: Wed, 20 Dec 2017 10:01:12 +0800 Subject: [PATCH 3/3] update style --- .../spark/mllib/clustering/BisectingKMeans.scala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala b/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala index bc29ad8a26c5f..9b9c70cfe5109 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeans.scala @@ -197,7 +197,9 @@ class BisectingKMeans private ( newClusters = summarize(d, newAssignments) newClusterCenters = newClusters.mapValues(_.center).map(identity) } - if (preIndices != null) preIndices.unpersist(blocking = false) + if (preIndices != null) { + preIndices.unpersist(false) + } preIndices = indices indices = updateAssignments(assignments, divisibleIndices, newClusterCenters).keys .persist(StorageLevel.MEMORY_AND_DISK) @@ -212,9 +214,13 @@ class BisectingKMeans private ( } level += 1 } - if (preIndices != null) preIndices.unpersist(blocking = false) - if (indices != null) indices.unpersist(blocking = false) - norms.unpersist(blocking = false) + if (preIndices != null) { + preIndices.unpersist(false) + } + if (indices != null) { + indices.unpersist(false) + } + norms.unpersist(false) val clusters = activeClusters ++ inactiveClusters val root = buildTree(clusters) new BisectingKMeansModel(root)