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:
-
Constructor Summary
ConstructorsConstructorDescriptionAvroSerializer(Class<T> type) Creates a new AvroSerializer for the type indicated by the given class.AvroSerializer(Class<T> type, org.apache.avro.Schema schema) Creates a new AvroSerializer for the type indicated by the given class. -
Method Summary
Modifier and TypeMethodDescriptionvoidcopy(org.apache.flink.core.memory.DataInputView source, org.apache.flink.core.memory.DataOutputView target) deserialize(org.apache.flink.core.memory.DataInputView source) deserialize(T reuse, org.apache.flink.core.memory.DataInputView source) org.apache.flink.api.common.typeutils.TypeSerializer<T>booleanintgetType()inthashCode()booleanvoidorg.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T>toString()
-
Constructor Details
-
AvroSerializer
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
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)
-
-
Method Details
-
getType
-
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
- 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
- Specified by:
deserializein classorg.apache.flink.api.common.typeutils.TypeSerializer<T>- Throws:
IOException
-
deserialize
- Specified by:
deserializein classorg.apache.flink.api.common.typeutils.TypeSerializer<T>- Throws:
IOException
-
copy
- Specified by:
copyin classorg.apache.flink.api.common.typeutils.TypeSerializer<T>
-
copy
- 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
- Specified by:
snapshotConfigurationin classorg.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
- Specified by:
equalsin classorg.apache.flink.api.common.typeutils.TypeSerializer<T>
-
toString
-