aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlok Singh <singhal@Aloks-MacBook-Pro.local>2015-07-02 09:58:57 -0700
committerXiangrui Meng <meng@databricks.com>2015-07-02 09:58:57 -0700
commit99c40cd0d8465525cac34dfa373b81532ef3d719 (patch)
tree9b778d421e1c4a418825dd315f9927c01162bbbe
parent246265f2bb056d5e9011d3331b809471a24ff8d7 (diff)
downloadspark-99c40cd0d8465525cac34dfa373b81532ef3d719.tar.gz
spark-99c40cd0d8465525cac34dfa373b81532ef3d719.tar.bz2
spark-99c40cd0d8465525cac34dfa373b81532ef3d719.zip
[SPARK-8647] [MLLIB] Potential issue with constant hashCode
I added the code, // see [SPARK-8647], this achieves the needed constant hash code without constant no. override def hashCode(): Int = this.getClass.getName.hashCode() does getting the constant hash code as per jira Author: Alok Singh <singhal@Aloks-MacBook-Pro.local> Closes #7146 from aloknsingh/aloknsingh_SPARK-8647 and squashes the following commits: e58bccf [Alok Singh] [SPARK-8647][MLlib] to avoid the class derivation issues, change the constant hashCode to override def hashCode(): Int = classOf[MatrixUDT].getName.hashCode() 43cdb89 [Alok Singh] [SPARK-8647][MLlib] Potential issue with constant hashCode
-rw-r--r--mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala3
-rw-r--r--mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala3
2 files changed, 4 insertions, 2 deletions
diff --git a/mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala b/mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala
index 85e63b1382..0a615494bb 100644
--- a/mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala
+++ b/mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala
@@ -193,7 +193,8 @@ private[spark] class MatrixUDT extends UserDefinedType[Matrix] {
}
}
- override def hashCode(): Int = 1994
+ // see [SPARK-8647], this achieves the needed constant hash code without constant no.
+ override def hashCode(): Int = classOf[MatrixUDT].getName.hashCode()
override def typeName: String = "matrix"
diff --git a/mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala b/mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala
index 2ffa497a99..c9c27425d2 100644
--- a/mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala
+++ b/mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala
@@ -234,7 +234,8 @@ private[spark] class VectorUDT extends UserDefinedType[Vector] {
}
}
- override def hashCode: Int = 7919
+ // see [SPARK-8647], this achieves the needed constant hash code without constant no.
+ override def hashCode(): Int = classOf[VectorUDT].getName.hashCode()
override def typeName: String = "vector"