diff options
author | Shivansh <shiv4nsh@gmail.com> | 2016-09-04 12:39:26 +0100 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-09-04 12:39:26 +0100 |
commit | e75c162e9e510d74b07f28ccf6c7948ac317a7c6 (patch) | |
tree | 3d424bc7733e9d7ccca8e929e914ceeced4c8e19 /mllib/src | |
parent | 6b156e2fcf9c0c1ed0770a7ad9c54fa374760e17 (diff) | |
download | spark-e75c162e9e510d74b07f28ccf6c7948ac317a7c6.tar.gz spark-e75c162e9e510d74b07f28ccf6c7948ac317a7c6.tar.bz2 spark-e75c162e9e510d74b07f28ccf6c7948ac317a7c6.zip |
[SPARK-17308] Improved the spark core code by replacing all pattern match on boolean value by if/else block.
## What changes were proposed in this pull request?
Improved the code quality of spark by replacing all pattern match on boolean value by if/else block.
## How was this patch tested?
By running the tests
Author: Shivansh <shiv4nsh@gmail.com>
Closes #14873 from shiv4nsh/SPARK-17308.
Diffstat (limited to 'mllib/src')
-rw-r--r-- | mllib/src/test/scala/org/apache/spark/mllib/clustering/KMeansSuite.scala | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/mllib/src/test/scala/org/apache/spark/mllib/clustering/KMeansSuite.scala b/mllib/src/test/scala/org/apache/spark/mllib/clustering/KMeansSuite.scala index 3003c62d98..2d35b31208 100644 --- a/mllib/src/test/scala/org/apache/spark/mllib/clustering/KMeansSuite.scala +++ b/mllib/src/test/scala/org/apache/spark/mllib/clustering/KMeansSuite.scala @@ -304,11 +304,10 @@ class KMeansSuite extends SparkFunSuite with MLlibTestSparkContext { object KMeansSuite extends SparkFunSuite { def createModel(dim: Int, k: Int, isSparse: Boolean): KMeansModel = { - val singlePoint = isSparse match { - case true => - Vectors.sparse(dim, Array.empty[Int], Array.empty[Double]) - case _ => - Vectors.dense(Array.fill[Double](dim)(0.0)) + val singlePoint = if (isSparse) { + Vectors.sparse(dim, Array.empty[Int], Array.empty[Double]) + } else { + Vectors.dense(Array.fill[Double](dim)(0.0)) } new KMeansModel(Array.fill[Vector](k)(singlePoint)) } |