Skip to content

Commit 0466c7a

Browse files
committed
Register PythonBroadcast with Kryo.
1 parent d5b409f commit 0466c7a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

core/src/main/scala/org/apache/spark/serializer/KryoSerializer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.esotericsoftware.kryo.serializers.{JavaSerializer => KryoJavaSerializ
2626
import com.twitter.chill.{AllScalaRegistrar, EmptyScalaKryoInstantiator}
2727

2828
import org.apache.spark._
29+
import org.apache.spark.api.python.PythonBroadcast
2930
import org.apache.spark.broadcast.HttpBroadcast
3031
import org.apache.spark.network.nio.{PutBlock, GotBlock, GetBlock}
3132
import org.apache.spark.scheduler.MapStatus
@@ -90,6 +91,7 @@ class KryoSerializer(conf: SparkConf)
9091
// Allow sending SerializableWritable
9192
kryo.register(classOf[SerializableWritable[_]], new KryoJavaSerializer())
9293
kryo.register(classOf[HttpBroadcast[_]], new KryoJavaSerializer())
94+
kryo.register(classOf[PythonBroadcast], new KryoJavaSerializer())
9395

9496
try {
9597
// Use the default classloader when calling the user registrator.

core/src/test/scala/org/apache/spark/api/python/PythonBroadcastSuite.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ import java.io.{PrintWriter, File}
2323

2424
import org.scalatest.{Matchers, FunSuite}
2525

26-
import org.apache.spark.SparkConf
26+
import org.apache.spark.{SharedSparkContext, SparkConf}
2727
import org.apache.spark.serializer.KryoSerializer
2828
import org.apache.spark.util.Utils
2929

30-
31-
class PythonBroadcastSuite extends FunSuite with Matchers {
30+
// This test suite uses SharedSparkContext because we need a SparkEnv in order to deserialize
31+
// a PythonBroadcast:
32+
class PythonBroadcastSuite extends FunSuite with Matchers with SharedSparkContext {
3233
test("PythonBroadcast can be serialized with Kryo (SPARK-4882)") {
3334
val tempDir = Utils.createTempDir()
3435
val broadcastedString = "Hello, world!"

0 commit comments

Comments
 (0)