-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-10914] UnsafeRow serialization breaks when two machines have different Oops size. #9030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,8 +89,13 @@ case class BroadcastHashJoin( | |
| // The following line doesn't run in a job so we cannot track the metric value. However, we | ||
| // have already tracked it in the above lines. So here we can use | ||
| // `SQLMetrics.nullLongMetric` to ignore it. | ||
|
|
||
| input.foreach { row => | ||
|
||
| println(row) | ||
| } | ||
|
|
||
| val hashed = HashedRelation( | ||
| input.iterator, SQLMetrics.nullLongMetric, buildSideKeyGenerator, input.size) | ||
| input.iterator, SQLMetrics.nullLongMetric, buildSideKeyGenerator, input.length) | ||
| sparkContext.broadcast(hashed) | ||
| } | ||
| }(BroadcastHashJoin.broadcastHashJoinExecutionContext) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,8 @@ package org.apache.spark.sql | |
|
|
||
| import java.io.ByteArrayOutputStream | ||
|
|
||
| import org.apache.spark.SparkFunSuite | ||
| import org.apache.spark.{SparkConf, SparkFunSuite} | ||
| import org.apache.spark.serializer.{KryoSerializer, JavaSerializer} | ||
| import org.apache.spark.sql.catalyst.InternalRow | ||
| import org.apache.spark.sql.catalyst.expressions.{UnsafeRow, UnsafeProjection} | ||
| import org.apache.spark.sql.types._ | ||
|
|
@@ -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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually doesn't matter anymore with new versions of ScalaTest. |
||
| } | ||
|
|
||
| test("bitset width calculation") { | ||
| assert(UnsafeRow.calculateBitSetWidthInBytes(0) === 0) | ||
| assert(UnsafeRow.calculateBitSetWidthInBytes(1) === 8) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this just call
writeExternal(out)?