Hi Martin,
Sorry I didn't see your message sooner!
Thinking about it briefly, there seems to be a couple ways to go about
it.
We could store the field names so we know what field each serialized
value belongs to. The downside is that the serialized data becomes
larger. The upside is that the programmer doesn't have to do anything
extra.
We could require a schema to be provided (like Protobuf does). The
schema would define a unique integer "id" for each field. This
minimizes the metadata that needs to be written for each field, but
requires the programmer to maintain a single schema.
We could require a schema for each possible deserialization (like Avro
does). This means metadata doesn't have to be written per field, but
requires the programmer to maintain multiple schemas.
Note to implement this doesn't require any core changes to Kryo, only
the addition of a new Serializer (or maybe it could be an optional
feature of FieldSerializer). You could even copy and paste
FieldSerializer and just add writing/reading the field name instead of
relying on the Java class definition. Hardest part is naming the new
serializer class! ;)
Unrelated to forward compatibility, you may find it annoying to have
to register each class to serialize. Because classes must be
registered in the same, specific order for deserialization, you will
probably have to expose the Kryo API to your users and require they
register their classes. A way around this might be to register classes
in the order they are encountered, and to persist this order so that
subsequent runs of your application can register the classes in the
same order. This falls apart if you remove one of the classes though.
Kryo could be enhanced to allow for the fully qualified class name to
be serialized instead of the registered class ID. This would remove
the need to register classes.
These issues are coming up because thus far Kryo has only been used
for network communication, where instead of these being issues, they
are features that keep the serialized size to a minimum. I am all for
making Kryo more general purpose to better suit your needs. I will
give it some more thought.
--
You received this message because you are subscribed to the "kryo-users" group.
http://groups.google.com/group/kryo-users
really cool!
Regarding ReflectASM: would it be possible to allow the user to use
it, e.g. if it's in the class path, then use reflect-asm, otherwise
java reflection? Although, you're right with the
force-spreading-the-word approach, I can absolutely follow you here
:-)
I want to add the option to use reflect-asm to existing (javolution)
serializers and I'm really looking forward seeing what speed
improvements it brings! Unfortunately I don't know yet how much time
is spent in reflection compared to e.g. writing serialized data.
As soon as I find some time I'll play with kryo again and try to
integrate it as a serializer. Right now I'm working on a release of
the memcached-session-manager (besides daily paid work :)), which I
hope to finish this or the next week...
Thanx && cheers,
Martin
> To unsubscribe from this group, send email to
> kryo-users+unsubscribegooglegroups.com or reply to this email with the words
> "REMOVE ME" as the subject.