Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/9030#discussion_r41553096
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/UnsafeRowSuite.scala
---
@@ -29,6 +30,32 @@ import org.apache.spark.unsafe.types.UTF8String
class UnsafeRowSuite extends SparkFunSuite {
+ test("UnsafeRow Java serialization") {
+ // serializing an UnsafeRow pointing to a large buffer should only
serialize the relevant data
+ val data = new Array[Byte](1024)
+ val row = new UnsafeRow
+ row.pointTo(data, 1, 16)
+ row.setLong(0, 19285)
+
+ val ser = new JavaSerializer(new SparkConf).newInstance()
+ val row1 = ser.deserialize[UnsafeRow](ser.serialize(row))
+ assert(row1.getLong(0) == 19285)
+ assert(row1.getBaseObject().asInstanceOf[Array[Byte]].length == 16)
+ }
+
+ test("UnsafeRow Kryo serialization") {
+ // serializing an UnsafeRow pointing to a large buffer should only
serialize the relevant data
+ val data = new Array[Byte](1024)
+ val row = new UnsafeRow
+ row.pointTo(data, 1, 16)
+ row.setLong(0, 19285)
+
+ val ser = new KryoSerializer(new SparkConf).newInstance()
+ val row1 = ser.deserialize[UnsafeRow](ser.serialize(row))
+ assert(row1.getLong(0) == 19285)
+ assert(row1.getBaseObject().asInstanceOf[Array[Byte]].length == 16)
--- End diff --
`===`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]