Saturday 15 May 2010

serialization - Java, Kryo: Add fields to class persisted as FieldSerializer -


This is using the Kryo serialization library

I already have an field Serializers are sorted for DB with . Now, I want to add some areas in series, and want to get backward compatibility with them.

Is this possible? What is the best way to do this?

I tried switching the deserializer to TaggedFieldSerializer , but it is not surprising that it does not work ( unassigned class ID:

1 update

If this is not clear, then I will first of all

There are some methods that come to mind (on this Depending on the fact that they are all JVM at the same time If you have to go through this process before adding new fields:

If you can keep them in memory:

    < Li> Reads all of these through a Kryo instance, use the Field Serializer , then write them through a different action example, which supports backwards compatibility. If you do not have enough RAM, you can Thayi to increase the configured size of the virtual memory for this exercise can increase VM heap size, although processing will be slower if required swapping large amounts.

If you can not keep all of these in memory:

  • Read them in one at a time through a Kryo frequency FieldSerializer then write them through a different action example, which supports backwards compatibility, with a similar schema in a separate table, or with a similar database schema as a separate database instance input ( If it is easy to do this Databse level).

In the form of the new serializer , the compatible field serializer will be the easiest, since the ordering variation can initially be any POJO field made without changes. After that you can make your necessary changes against the new compatible field serializer serial object. Alternatively (I have not tried to do this), you can try commenting the fields according to the TaggedFieldSerializer requirements, and follow the same steps - as long as the field serializer < Code> Tagged filtered consultant while reading in the objects


No comments:

Post a Comment