Little get started for serializer
QIvan opened this issue · 4 comments
Is there any tutorial 'hot to use serializer'?
I have serveral questions:
- Did I right understand that a work do through
- one.nio.serial.Serializer#serialize
- one.nio.serial.Serializer#deserialize
Is it the best (for perfomance) way?
- What is the difference between persist and serialize?
- You told that there is a feature to request a schema. I didn't find it =(
- Can I add a custom Serializer for my type?
Thanks!
There is no tutorial, sorry. I'll be glad with any help on writing this.
-
Right, this is a basic part of serialization API, and it is supposed to be fast.
-
persist
embeds serialization schema into the output array, so that resultbyte[]
is self-sufficient for deserialization, even in a different JVM on a different machine.serialize
produces smaller output as it does not store full schema, only the schema fingerprint. It also works faster. In order to decode data produced byserialize
, all custom (non-bootstrap) serializers must be present in Repository.deserialize
can decode both kinds of data. -
Automatic schema management is built into one-nio RPC mechanism, see RpcClient.invoke(). When making a remote call, a client may request an unknown schema from a server, or it may provide its own schema to a server if the other side responds with
SerializerNotFoundException
. Schema exchange is implemented using the same RPC request-response mechanism.
Out of RPC scope an application may implement its own schema management, e.g. a central database for schemas. The simplest way to store schemas is to call saveSnapshot
which will make the complete persistable representation of current Repository state.
- Yes. Extend
Serializer
class, and register it usingRepository.provideSerializer
.
many thanks for answers!
I hope I will be able to help you with tutorial.