@Internal public class TypeSerializerSerializationUtil extends Object
TypeSerializer
and TypeSerializerConfigSnapshot
.Modifier and Type | Class and Description |
---|---|
static class |
TypeSerializerSerializationUtil.TypeSerializerSerializationProxy<T>
Utility serialization proxy for a
TypeSerializer . |
Constructor and Description |
---|
TypeSerializerSerializationUtil() |
public static <T> void writeSerializer(DataOutputView out, TypeSerializer<T> serializer) throws IOException
TypeSerializer
to the provided data output view.
It is written with a format that can be later read again using
tryReadSerializer(DataInputView, ClassLoader, boolean)
.
T
- Data type of the serializer.out
- the data output view.serializer
- the serializer to write.IOException
public static <T> TypeSerializer<T> tryReadSerializer(DataInputView in, ClassLoader userCodeClassLoader)
TypeSerializer
that was previously
written using writeSerializer(DataOutputView, TypeSerializer)
.
If deserialization fails for any reason (corrupted serializer bytes, serializer class
no longer in classpath, serializer class no longer valid, etc.), null
will
be returned instead.
T
- Data type of the serializer.in
- the data input view.userCodeClassLoader
- the user code class loader to use.public static <T> TypeSerializer<T> tryReadSerializer(DataInputView in, ClassLoader userCodeClassLoader, boolean useDummyPlaceholder)
TypeSerializer
that was previously
written using writeSerializer(DataOutputView, TypeSerializer)
.
If deserialization fails due to ClassNotFoundException
or InvalidClassException
,
users can opt to use a dummy UnloadableDummyTypeSerializer
to hold the serializer bytes,
otherwise null
is returned. If the failure is due to a StreamCorruptedException
,
then null
is returned.
T
- Data type of the serializer.in
- the data input view.userCodeClassLoader
- the user code class loader to use.useDummyPlaceholder
- whether or not to use a dummy UnloadableDummyTypeSerializer
to hold the
serializer bytes in the case of a ClassNotFoundException
or
InvalidClassException
.public static void writeSerializersAndConfigsWithResilience(DataOutputView out, List<Tuple2<TypeSerializer<?>,TypeSerializerConfigSnapshot>> serializersAndConfigs) throws IOException
readSerializersAndConfigsWithResilience(DataInputView, ClassLoader)
, if
deserialization of the serializer fails, its configuration snapshot will remain intact.
Specifically, all written serializers and their config snapshots are indexed by their offset positions within the serialized bytes. The serialization format is as follows:
out
- the data output view.serializersAndConfigs
- serializer and configuration snapshot pairsIOException
public static List<Tuple2<TypeSerializer<?>,TypeSerializerConfigSnapshot>> readSerializersAndConfigsWithResilience(DataInputView in, ClassLoader userCodeClassLoader) throws IOException
writeSerializersAndConfigsWithResilience(DataOutputView, List)
.
This is fault tolerant to any failures when deserializing the serializers. Serializers which
were not successfully deserialized will be replaced by null
.in
- the data input view.userCodeClassLoader
- the user code class loader to use.IOException
public static void writeSerializerConfigSnapshot(DataOutputView out, TypeSerializerConfigSnapshot serializerConfigSnapshot) throws IOException
TypeSerializerConfigSnapshot
to the provided data output view.
It is written with a format that can be later read again using
readSerializerConfigSnapshot(DataInputView, ClassLoader)
.
out
- the data output viewserializerConfigSnapshot
- the serializer configuration snapshot to writeIOException
public static TypeSerializerConfigSnapshot readSerializerConfigSnapshot(DataInputView in, ClassLoader userCodeClassLoader) throws IOException
TypeSerializerConfigSnapshot
that was previously
written using writeSerializerConfigSnapshot(DataOutputView, TypeSerializerConfigSnapshot)
.in
- the data input viewuserCodeClassLoader
- the user code class loader to useIOException
public static void writeSerializerConfigSnapshots(DataOutputView out, TypeSerializerConfigSnapshot... serializerConfigSnapshots) throws IOException
TypeSerializerConfigSnapshot
s to the provided data output view.
It is written with a format that can be later read again using
readSerializerConfigSnapshots(DataInputView, ClassLoader)
.
out
- the data output viewserializerConfigSnapshots
- the serializer configuration snapshots to writeIOException
public static TypeSerializerConfigSnapshot[] readSerializerConfigSnapshots(DataInputView in, ClassLoader userCodeClassLoader) throws IOException
TypeSerializerConfigSnapshot
s that was previously
written using writeSerializerConfigSnapshot(DataOutputView, TypeSerializerConfigSnapshot)
.in
- the data input viewuserCodeClassLoader
- the user code class loader to useIOException
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.