I am using Kryo with Spark.
I have been mostly serializing/deserializing AVRO objects and that has been working great by using twitter chill serializer.
However, I am now running into the following NullPointerException when deserializing a case class that contains an array:
com.esotericsoftware.kryo.KryoException: java.lang.NullPointerException
Serialization trace:
underlying (scala.collection.convert.Wrappers$JListWrapper)
myArrayField (MyCaseClass)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125)
I found this stack overflow that seems to be relevant:
I have this line of code translated to Scala, that supposedly solves the issue:
val kryo = new Kryo()
kryo.getInstantiatorStrategy().asInstanceOf[Kryo.DefaultInstantiatorStrategy].setFallbackInstantiatorStrategy(new StdInstantiatorStrategy())
However, I am not sure where this line should be placed to take effect, since in Spark we don't explicitly instantiate kryo anywhere.
I already have the following, should it go somewhere in here?
class MyRegistrator extends KryoRegistrator {
override def registerClasses(kryo: Kryo) {
kryo.register(...)
}
}