简体   繁体   English

Kryo序列化空反序列化

[英]Kryo Serialization empty Deserialization

I refactor my code to work with kryo serialization. 我将代码重构为可用于kryo序列化。 Everything works fine except deserialize a property of geomtry from certain class. 除了反序列化某些类的geomtry属性外,一切都正常。 No exception is thrown (I set "spark.kryo.registrationRequired" to true). 没有引发异常(我将“ spark.kryo.registrationRequired”设置为true)。 On debug I try to collect the data and I see that the data in the geomtry is just empty. 在调试时,我尝试收集数据,并且我发现几何体中的数据只是空的。 As a result I understand that the deserialize was fail. 结果,我知道反序列化失败。 Geomtry is from type of - Any(scala) because it is a complex property maybe. 几何来自-Any(scala)类型,因为它可能是一个复杂的属性。 My question is why the data is empty, And is there connection to the type 'Any' of the property. 我的问题是为什么数据为空,并且与属性的“ Any”类型相关?

Update : 更新:

class code: class Entity(val id:String) extends Serializable{ 类代码:类Entity(val id:String)扩展了Serializable {

var index:Any = null var index:Any = null

var geometry:Any = null var geometry:Any = null

} }

geometry contains centeroid, shape and coordinates(complex object) 几何包含心形,形状和坐标(复杂对象)

You should not use Kryo with Scala since the behavior of many Scala classes differs from Java classes and Kryo was originally written to work with Java. 您不应将Kryo与Scala一起使用,因为许多Scala类的行为不同于Java类,并且Kryo最初是为与Java一起使用而编写的。 You will probably encounter many weird issues like this one if you use Kryo with Scala. 如果将Scry和Kryo​​一起使用,您可能会遇到许多奇怪的问题。 You should instead use chill-scala which is an extension of Kryo that handles all of Scala's special cases. 相反,您应该使用chill-scala ,它是Kryo的扩展,可以处理Scala的所有特殊情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM