我不明白为 kryo 序列化注册一个类意味着什么。 提供一些背景link这里说的是
Kryo does not support all Serializable types and requires you to register the classes you’ll use in the program in advance for best performance.
我又不明白注册类是什么意思?从应用相同的逻辑来序列化所有类型的对象的意义上来说,序列化代码不是静态的吗?那么提前提及将要序列化的类对以后有什么帮助呢?
谢谢!
最佳答案
Kyro docs提到提前注册不是必需的,但可以提高性能,因为第一次遇到类时不需要序列化类的名称;可以使用注册期间生成的 来代替,这也会导致使用更少的字节。
摘录:
When Kryo writes out an instance of an object, first it may need to write out something that identifies the object's class. By default, the fully qualified class name is written, then the bytes for the object. Subsequent appearances of that object type within the same object graph are written using a variable length int. Writing the class name is somewhat inefficient, so classes can be registered beforehand:
关于java - 使用kryo序列化注册类的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44633410/