From 99c40cd0d8465525cac34dfa373b81532ef3d719 Mon Sep 17 00:00:00 2001 From: Alok Singh Date: Thu, 2 Jul 2015 09:58:57 -0700 Subject: [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 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 --- mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala | 3 ++- mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala | 3 ++- 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" -- cgit v1.2.3