E - The data type serialized / deserialized by this serializer.@Internal public interface SimpleVersionedSerializer<E> extends Versioned
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 |
|---|---|
E |
deserialize(int version,
byte[] serialized)
De-serializes the given data (bytes) which was serialized with the scheme of the
indicated version.
|
int |
getVersion()
Gets the version with which this serializer serializes.
|
byte[] |
serialize(E obj)
Serializes the given object.
|
int getVersion()
getVersion in interface Versionedbyte[] serialize(E obj) throws IOException
getVersion().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 serializedserialized - The serialized dataIOException - Thrown, if the deserialization fails.Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.