diff options
author | Jakob Odersky <jakob@odersky.com> | 2016-03-16 16:59:36 -0700 |
---|---|---|
committer | Xiangrui Meng <meng@databricks.com> | 2016-03-16 16:59:36 -0700 |
commit | d4d84936fb82bee91f4b04608de9f75c293ccc9e (patch) | |
tree | 9cbaeb2ad0de147a9febe516c2fd537fbbb9263c /mllib | |
parent | 77ba3021c12dc63cb7d831f964f901e0474acd96 (diff) | |
download | spark-d4d84936fb82bee91f4b04608de9f75c293ccc9e.tar.gz spark-d4d84936fb82bee91f4b04608de9f75c293ccc9e.tar.bz2 spark-d4d84936fb82bee91f4b04608de9f75c293ccc9e.zip |
[SPARK-11011][SQL] Narrow type of UDT serialization
## What changes were proposed in this pull request?
Narrow down the parameter type of `UserDefinedType#serialize()`. Currently, the parameter type is `Any`, however it would logically make more sense to narrow it down to the type of the actual user defined type.
## How was this patch tested?
Existing tests were successfully run on local machine.
Author: Jakob Odersky <jakob@odersky.com>
Closes #11379 from jodersky/SPARK-11011-udt-types.
Diffstat (limited to 'mllib')
-rw-r--r-- | mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala | 2 | ||||
-rw-r--r-- | mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala | 2 |
2 files changed, 2 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 fdede2ad39..157f2dbf5d 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 @@ -177,7 +177,7 @@ private[spark] class MatrixUDT extends UserDefinedType[Matrix] { )) } - override def serialize(obj: Any): InternalRow = { + override def serialize(obj: Matrix): InternalRow = { val row = new GenericMutableRow(7) obj match { case sm: SparseMatrix => 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 cecfd067bd..0f0c3a2df5 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 @@ -203,7 +203,7 @@ class VectorUDT extends UserDefinedType[Vector] { StructField("values", ArrayType(DoubleType, containsNull = false), nullable = true))) } - override def serialize(obj: Any): InternalRow = { + override def serialize(obj: Vector): InternalRow = { obj match { case SparseVector(size, indices, values) => val row = new GenericMutableRow(4) |