E- The data type serialized / deserialized by this serializer.
The serializer has a version (returned by
getVersion()) which can be attached to the
serialized data. When the serializer evolves, the version can be used to identify with which
prior version the data was serialized.
MyType someObject = ...; SimpleVersionedSerializer<MyType> serializer = ...; byte serializedData = serializer.serialize(someObject); int version = serializer.getVersion(); MyType deserialized = serializer.deserialize(version, serializedData); byte someOldData = ...; int oldVersion = ...; MyType deserializedOldObject = serializer.deserialize(oldVersion, someOldData);
|Modifier and Type||Method and Description|
De-serializes the given data (bytes) which was serialized with the scheme of the indicated version.
Gets the version with which this serializer serializes.
Serializes the given object.
byte serialize(E obj) throws IOException
obj- The object to serialize.
IOException- Thrown, if the serialization fails.
E deserialize(int version, byte serialized) throws IOException
version- The version in which the data was serialized
serialized- The serialized data
IOException- Thrown, if the deserialization fails.
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.