diff options
author | Joan <joan@goyeau.com> | 2016-04-22 12:24:12 +0100 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-04-22 12:24:12 +0100 |
commit | bf95b8da2774620cd62fa36bd8bf37725ad3fc7d (patch) | |
tree | b257a13641f72ed5b0b0eff34ef0bf64374c7c1d /mllib-local/src/main | |
parent | e09ab5da8b02da98d7b2496d549c1d53cceb8728 (diff) | |
download | spark-bf95b8da2774620cd62fa36bd8bf37725ad3fc7d.tar.gz spark-bf95b8da2774620cd62fa36bd8bf37725ad3fc7d.tar.bz2 spark-bf95b8da2774620cd62fa36bd8bf37725ad3fc7d.zip |
[SPARK-6429] Implement hashCode and equals together
## What changes were proposed in this pull request?
Implement some `hashCode` and `equals` together in order to enable the scalastyle.
This is a first batch, I will continue to implement them but I wanted to know your thoughts.
Author: Joan <joan@goyeau.com>
Closes #12157 from joan38/SPARK-6429-HashCode-Equals.
Diffstat (limited to 'mllib-local/src/main')
-rw-r--r-- | mllib-local/src/main/scala/org/apache/spark/ml/linalg/Matrices.scala | 2 | ||||
-rw-r--r-- | mllib-local/src/main/scala/org/apache/spark/ml/linalg/Vectors.scala | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Matrices.scala b/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Matrices.scala index baa04fb0fd..8204b5af02 100644 --- a/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Matrices.scala +++ b/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Matrices.scala @@ -458,6 +458,8 @@ class SparseMatrix ( rowIndices: Array[Int], values: Array[Double]) = this(numRows, numCols, colPtrs, rowIndices, values, false) + override def hashCode(): Int = toBreeze.hashCode() + override def equals(o: Any): Boolean = o match { case m: Matrix => toBreeze == m.toBreeze case _ => false diff --git a/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Vectors.scala b/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Vectors.scala index fd4ce9adb8..4275a22ae0 100644 --- a/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Vectors.scala +++ b/mllib-local/src/main/scala/org/apache/spark/ml/linalg/Vectors.scala @@ -476,6 +476,8 @@ class DenseVector (val values: Array[Double]) extends Vector { } } + override def equals(other: Any): Boolean = super.equals(other) + override def hashCode(): Int = { var result: Int = 31 + size var i = 0 @@ -602,6 +604,8 @@ class SparseVector ( } } + override def equals(other: Any): Boolean = super.equals(other) + override def hashCode(): Int = { var result: Int = 31 + size val end = values.length |