Package org.apache.flink.core.io
Interface SimpleVersionedSerializer<E>
-
- Type Parameters:
E- The data type serialized / deserialized by this serializer.
- All Superinterfaces:
Versioned
- All Known Implementing Classes:
SimpleVersionedSerializerAdapter
@PublicEvolving public interface SimpleVersionedSerializer<E> extends Versioned
A simple serializer interface for versioned serialization.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);
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Edeserialize(int version, byte[] serialized)De-serializes the given data (bytes) which was serialized with the scheme of the indicated version.intgetVersion()Gets the version with which this serializer serializes.byte[]serialize(E obj)Serializes the given object.
-
-
-
Method Detail
-
getVersion
int getVersion()
Gets the version with which this serializer serializes.- Specified by:
getVersionin interfaceVersioned- Returns:
- The version of the serialization schema.
-
serialize
byte[] serialize(E obj) throws IOException
Serializes the given object. The serialization is assumed to correspond to the current serialization version (as returned bygetVersion().- Parameters:
obj- The object to serialize.- Returns:
- The serialized data (bytes).
- Throws:
IOException- Thrown, if the serialization fails.
-
deserialize
E deserialize(int version, byte[] serialized) throws IOException
De-serializes the given data (bytes) which was serialized with the scheme of the indicated version.- Parameters:
version- The version in which the data was serializedserialized- The serialized data- Returns:
- The deserialized object
- Throws:
IOException- Thrown, if the deserialization fails.
-
-