From f7a3ca25337a5d7ee025133f22e6873c97f3860e Mon Sep 17 00:00:00 2001 From: Xusen Yin Date: Wed, 2 Apr 2014 18:14:52 +0800 Subject: [PATCH] fix the corner case of maxmin --- .../org/apache/spark/mllib/rdd/VectorRDDFunctions.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mllib/src/main/scala/org/apache/spark/mllib/rdd/VectorRDDFunctions.scala b/mllib/src/main/scala/org/apache/spark/mllib/rdd/VectorRDDFunctions.scala index 23623e2a28309..736fc363f2e5d 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/rdd/VectorRDDFunctions.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/rdd/VectorRDDFunctions.scala @@ -59,16 +59,16 @@ private class Aggregator( override def max(): Vector = { nnz.activeIterator.foreach { - case (id, 0.0) => currMax(id) = 0.0 - case _ => + case (id, count) => + if ((count == 0.0) || ((count < totalCnt) && (currMax(id) < 0.0))) currMax(id) = 0.0 } Vectors.fromBreeze(currMax) } override def min(): Vector = { nnz.activeIterator.foreach { - case (id, 0.0) => currMin(id) = 0.0 - case _ => + case (id, count) => + if ((count == 0.0) || ((count < totalCnt) && (currMin(id) > 0.0))) currMin(id) = 0.0 } Vectors.fromBreeze(currMin) }