我无法通过scala上使用Kryo的最简单的序列化示例。 我需要为此注册特定的序列化器吗? 感谢
val kryo = new Kryo()
kryo.setRegistrationRequired(false)
kryo.register(classOf[scala.Tuple2[Any, Any]])
val intstringtuple = (100, "somestring")
val outStream = new ByteArrayOutputStream()
val output = new Output(outStream)
kryo.writeClassAndObject(output, obj)
output.flush()
val input = new com.esotericsoftware.kryo.io.Input(new ByteArrayInputStream(outStream.toByteArray))
val obj1 = kryo.readClassAndObject(input)
答案 0 :(得分:0)
添加以下内容可解决问题:
kryo.register(classOf[scala.Tuple2[Any, Any]], new com.twitter.chill.Tuple2Serializer)