com.esotericsoftware.kryo.serializers

Class CompatibleFieldSerializer<T>

  • All Implemented Interfaces:
    Comparator<FieldSerializer.CachedField>


    public class CompatibleFieldSerializer<T>extends FieldSerializer<T>
    Serializes objects using direct field assignment, with limited support for forward and backward compatibility. Fields can be added or removed without invalidating previously serialized bytes. Note that changing the type of a field is not supported.

    There is additional overhead compared to FieldSerializer. A header is output the first time an object of a given type is serialized. The header consists of an int for the number of fields, then a String for each field name. Also, to support skipping the bytes for a field that no longer exists, for each field value an int is written that is the length of the value in bytes.

    Note that the field data is identified by name. The situation where a super class has a field with the same name as a subclass must be avoided.

    Author:
    Nathan Sweet
    • Constructor Detail

      • CompatibleFieldSerializer

        public CompatibleFieldSerializer(Kryo kryo,                         Class type)
    • Method Detail

      • write

        public void write(Kryo kryo,         Output output,         T object)
        Description copied from class: FieldSerializer
        This method can be called for different fields having the same type. Even though the raw type is the same, if the type is generic, it could happen that different concrete classes are used to instantiate it. Therefore, in case of different instantiation parameters, the fields analysis should be repeated. TODO: Cache serializer instances generated for a given set of generic parameters. Reuse it later instead of recomputing every time.
        Overrides:
        write in class FieldSerializer<T>
        object - May be null if Serializer.getAcceptsNull() is true.
      • read

        public T read(Kryo kryo,     Input input,     Class<T> type)
        Description copied from class: Serializer
        Reads bytes and returns a new object of the specified concrete type.

        Before Kryo can be used to read child objects, Kryo.reference(Object) must be called with the parent object to ensure it can be referenced by the child objects. Any serializer that uses Kryo to read a child object may need to be reentrant.

        This method should not be called directly, instead this serializer can be passed to Kryo read methods that accept a serialier.

        Overrides:
        read in class FieldSerializer<T>
        Returns:
        May be null if Serializer.getAcceptsNull() is true.

Copyright © 2013. All Rights Reserved.



NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14