I don't understand what does it mean to register a class for kryo serialization. To give some background the link here says that
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.
Again, I don't understand what is the meaning of registering a class? Isn't the serialization code static in the sense that you apply the same logic to serialize all kinds of objects. How could mentioning in advanced the classes that will be serialized be helpful later then?
Thanks!
The Kyro docs mention that registering in advance is not necessary but increases performance as the first time a class is encountered the name of the class does not need to be serialized; the is generated during registration can be used instead, which also results in fewer bytes used.
Excerpt:
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: