spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [06/10] git commit: Style fix using 'if' rather than 'match' on boolean
Date Wed, 09 Oct 2013 06:45:13 GMT
Style fix using 'if' rather than 'match' on boolean


Project: http://git-wip-us.apache.org/repos/asf/incubator-spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spark/commit/c6ceaeae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spark/tree/c6ceaeae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spark/diff/c6ceaeae

Branch: refs/heads/master
Commit: c6ceaeae50c7b5d69bb9897af32f537bfbde152d
Parents: 6a7836c
Author: Nick Pentreath <nick.pentreath@gmail.com>
Authored: Fri Oct 4 13:52:53 2013 +0200
Committer: Nick Pentreath <nick.pentreath@gmail.com>
Committed: Fri Oct 4 13:52:53 2013 +0200

----------------------------------------------------------------------
 .../apache/spark/mllib/recommendation/ALS.scala | 27 ++++++++++----------
 1 file changed, 13 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spark/blob/c6ceaeae/mllib/src/main/scala/org/apache/spark/mllib/recommendation/ALS.scala
----------------------------------------------------------------------
diff --git a/mllib/src/main/scala/org/apache/spark/mllib/recommendation/ALS.scala b/mllib/src/main/scala/org/apache/spark/mllib/recommendation/ALS.scala
index 5935d27..36853ac 100644
--- a/mllib/src/main/scala/org/apache/spark/mllib/recommendation/ALS.scala
+++ b/mllib/src/main/scala/org/apache/spark/mllib/recommendation/ALS.scala
@@ -207,20 +207,19 @@ class ALS private (var numBlocks: Int, var rank: Int, var iterations:
Int, var l
    * @return Option[YtY] - whose value is only used in the implicit preference model
    */
   def computeYtY(factors: RDD[(Int, Array[Array[Double]])]) = {
-    implicitPrefs match {
-      case true => {
-        Option(
-          factors.flatMapValues{ case factorArray =>
-            factorArray.map{ vector =>
-              val x = new DoubleMatrix(vector)
-              x.mmul(x.transpose())
-            }
-          }.reduceByKeyLocally((a, b) => a.addi(b))
-           .values
-           .reduce((a, b) => a.addi(b))
-        )
-      }
-      case false => None
+    if (implicitPrefs) {
+      Option(
+        factors.flatMapValues{ case factorArray =>
+          factorArray.map{ vector =>
+            val x = new DoubleMatrix(vector)
+            x.mmul(x.transpose())
+          }
+        }.reduceByKeyLocally((a, b) => a.addi(b))
+         .values
+         .reduce((a, b) => a.addi(b))
+      )
+    } else {
+      None
     }
   }
 


Mime
View raw message