Class AvroSerializer<T>
- java.lang.Object
-
- org.apache.flink.api.common.typeutils.TypeSerializer<T>
-
- org.apache.flink.formats.avro.typeutils.AvroSerializer<T>
-
- Type Parameters:
T- The type to be serialized.
- All Implemented Interfaces:
Serializable
public class AvroSerializer<T> extends org.apache.flink.api.common.typeutils.TypeSerializer<T>A serializer that serializes types via Avro.The serializer supports:
- efficient specific record serialization for types generated via Avro
- serialization via reflection (ReflectDatumReader / -Writer)
- serialization of generic records via GenericDatumReader / -Writer
The serializer instantiates them depending on the class of the type it should serialize.
Important: This serializer is NOT THREAD SAFE, because it reuses the data encoders and decoders which have buffers that would be shared between the threads if used concurrently
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAvroSerializer.AvroSchemaSerializerConfigSnapshot<T>Deprecated.
-
Constructor Summary
Constructors Constructor Description AvroSerializer(Class<T> type)Creates a new AvroSerializer for the type indicated by the given class.AvroSerializer(Class<T> type, Class<? extends T> typeToInstantiate)Deprecated.UseAvroSerializer(Class)instead.AvroSerializer(Class<T> type, org.apache.avro.Schema schema)Creates a new AvroSerializer for the type indicated by the given class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopy(org.apache.flink.core.memory.DataInputView source, org.apache.flink.core.memory.DataOutputView target)Tcopy(T from)Tcopy(T from, T reuse)TcreateInstance()Tdeserialize(org.apache.flink.core.memory.DataInputView source)Tdeserialize(T reuse, org.apache.flink.core.memory.DataInputView source)org.apache.flink.api.common.typeutils.TypeSerializer<T>duplicate()booleanequals(Object obj)intgetLength()Class<T>getType()inthashCode()booleanisImmutableType()voidserialize(T value, org.apache.flink.core.memory.DataOutputView target)org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T>snapshotConfiguration()StringtoString()
-
-
-
Constructor Detail
-
AvroSerializer
public AvroSerializer(Class<T> type)
Creates a new AvroSerializer for the type indicated by the given class. This constructor is intended to be used withSpecificRecordor reflection serializer. For serializingGenericData.RecorduseAvroSerializer(Class, Schema)
-
AvroSerializer
public AvroSerializer(Class<T> type, org.apache.avro.Schema schema)
Creates a new AvroSerializer for the type indicated by the given class. This constructor is expected to be used only withGenericData.Record. ForSpecificRecordor reflection serializer useAvroSerializer(Class)
-
AvroSerializer
@Deprecated public AvroSerializer(Class<T> type, Class<? extends T> typeToInstantiate)
Deprecated.UseAvroSerializer(Class)instead.
-
-
Method Detail
-
isImmutableType
public boolean isImmutableType()
- Specified by:
isImmutableTypein classorg.apache.flink.api.common.typeutils.TypeSerializer<T>
-
getLength
public int getLength()
- Specified by:
getLengthin classorg.apache.flink.api.common.typeutils.TypeSerializer<T>
-
createInstance
public T createInstance()
- Specified by:
createInstancein classorg.apache.flink.api.common.typeutils.TypeSerializer<T>
-
serialize
public void serialize(T value, org.apache.flink.core.memory.DataOutputView target) throws IOException
- Specified by:
serializein classorg.apache.flink.api.common.typeutils.TypeSerializer<T>- Throws:
IOException
-
deserialize
public T deserialize(org.apache.flink.core.memory.DataInputView source) throws IOException
- Specified by:
deserializein classorg.apache.flink.api.common.typeutils.TypeSerializer<T>- Throws:
IOException
-
deserialize
public T deserialize(T reuse, org.apache.flink.core.memory.DataInputView source) throws IOException
- Specified by:
deserializein classorg.apache.flink.api.common.typeutils.TypeSerializer<T>- Throws:
IOException
-
copy
public T copy(T from)
- Specified by:
copyin classorg.apache.flink.api.common.typeutils.TypeSerializer<T>
-
copy
public T copy(T from, T reuse)
- Specified by:
copyin classorg.apache.flink.api.common.typeutils.TypeSerializer<T>
-
copy
public void copy(org.apache.flink.core.memory.DataInputView source, org.apache.flink.core.memory.DataOutputView target) throws IOException- Specified by:
copyin classorg.apache.flink.api.common.typeutils.TypeSerializer<T>- Throws:
IOException
-
snapshotConfiguration
public org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T> snapshotConfiguration()
- Specified by:
snapshotConfigurationin classorg.apache.flink.api.common.typeutils.TypeSerializer<T>
-
duplicate
public org.apache.flink.api.common.typeutils.TypeSerializer<T> duplicate()
- Specified by:
duplicatein classorg.apache.flink.api.common.typeutils.TypeSerializer<T>
-
hashCode
public int hashCode()
- Specified by:
hashCodein classorg.apache.flink.api.common.typeutils.TypeSerializer<T>
-
equals
public boolean equals(Object obj)
- Specified by:
equalsin classorg.apache.flink.api.common.typeutils.TypeSerializer<T>
-
-