Package org.apache.flink.formats.avro
Class AvroRowDataDeserializationSchema
- java.lang.Object
-
- org.apache.flink.formats.avro.AvroRowDataDeserializationSchema
-
- All Implemented Interfaces:
Serializable
,DeserializationSchema<RowData>
,ResultTypeQueryable<RowData>
@PublicEvolving public class AvroRowDataDeserializationSchema extends Object implements DeserializationSchema<RowData>
Deserialization schema from Avro bytes toRowData
.Deserializes the
byte[]
messages into (nested) Flink RowData. It converts Avro types into types that are compatible with Flink's Table & SQL API.Projects with Avro records containing logical date/time types need to add a JodaTime dependency.
Note: Changes in this class need to be kept in sync with the corresponding runtime class
AvroRowDataSerializationSchema
and schema converterAvroSchemaConverter
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.api.common.serialization.DeserializationSchema
DeserializationSchema.InitializationContext
-
-
Constructor Summary
Constructors Constructor Description AvroRowDataDeserializationSchema(DeserializationSchema<org.apache.avro.generic.GenericRecord> nestedSchema, AvroToRowDataConverters.AvroToRowDataConverter runtimeConverter, TypeInformation<RowData> typeInfo)
Creates a Avro deserialization schema for the given logical type.AvroRowDataDeserializationSchema(RowType rowType, TypeInformation<RowData> typeInfo)
Creates an Avro deserialization schema for the given logical type.AvroRowDataDeserializationSchema(RowType rowType, TypeInformation<RowData> typeInfo, AvroFormatOptions.AvroEncoding encoding)
Creates an Avro deserialization schema for the given logical type.AvroRowDataDeserializationSchema(RowType rowType, TypeInformation<RowData> typeInfo, AvroFormatOptions.AvroEncoding encoding, boolean legacyTimestampMapping)
Creates an Avro deserialization schema for the given logical type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RowData
deserialize(byte[] message)
Deserializes the byte message.boolean
equals(Object o)
TypeInformation<RowData>
getProducedType()
Gets the data type (as aTypeInformation
) produced by this function or input format.int
hashCode()
boolean
isEndOfStream(RowData nextElement)
Method to decide whether the element signals the end of the stream.void
open(DeserializationSchema.InitializationContext context)
Initialization method for the schema.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.api.common.serialization.DeserializationSchema
deserialize
-
-
-
-
Constructor Detail
-
AvroRowDataDeserializationSchema
public AvroRowDataDeserializationSchema(RowType rowType, TypeInformation<RowData> typeInfo)
Creates an Avro deserialization schema for the given logical type.- Parameters:
rowType
- The logical type used to deserialize the data.typeInfo
- The TypeInformation to be used bygetProducedType()
.
-
AvroRowDataDeserializationSchema
public AvroRowDataDeserializationSchema(RowType rowType, TypeInformation<RowData> typeInfo, AvroFormatOptions.AvroEncoding encoding)
Creates an Avro deserialization schema for the given logical type.- Parameters:
rowType
- The logical type used to deserialize the data.typeInfo
- The TypeInformation to be used bygetProducedType()
.encoding
- The serialization approach used to deserialize the data.
-
AvroRowDataDeserializationSchema
public AvroRowDataDeserializationSchema(RowType rowType, TypeInformation<RowData> typeInfo, AvroFormatOptions.AvroEncoding encoding, boolean legacyTimestampMapping)
Creates an Avro deserialization schema for the given logical type.- Parameters:
rowType
- The logical type used to deserialize the data.typeInfo
- The TypeInformation to be used bygetProducedType()
.encoding
- The serialization approach used to deserialize the data.legacyTimestampMapping
- Whether to use legacy timestamp mapping.
-
AvroRowDataDeserializationSchema
public AvroRowDataDeserializationSchema(DeserializationSchema<org.apache.avro.generic.GenericRecord> nestedSchema, AvroToRowDataConverters.AvroToRowDataConverter runtimeConverter, TypeInformation<RowData> typeInfo)
Creates a Avro deserialization schema for the given logical type.- Parameters:
nestedSchema
- Deserialization schema to deserialize asGenericRecord
runtimeConverter
- Converter that transforms aGenericRecord
intoRowData
typeInfo
- The TypeInformation to be used bygetProducedType()
-
-
Method Detail
-
open
public void open(DeserializationSchema.InitializationContext context) throws Exception
Description copied from interface:DeserializationSchema
Initialization method for the schema. It is called before the actual working methodsDeserializationSchema.deserialize(byte[])
and thus suitable for one time setup work.The provided
DeserializationSchema.InitializationContext
can be used to access additional features such as e.g. registering user metrics.- Specified by:
open
in interfaceDeserializationSchema<RowData>
- Parameters:
context
- Contextual information that can be used during initialization.- Throws:
Exception
-
deserialize
public RowData deserialize(@Nullable byte[] message) throws IOException
Description copied from interface:DeserializationSchema
Deserializes the byte message.- Specified by:
deserialize
in interfaceDeserializationSchema<RowData>
- Parameters:
message
- The message, as a byte array.- Returns:
- The deserialized message as an object (null if the message cannot be deserialized).
- Throws:
IOException
-
isEndOfStream
public boolean isEndOfStream(RowData nextElement)
Description copied from interface:DeserializationSchema
Method to decide whether the element signals the end of the stream. If true is returned the element won't be emitted.- Specified by:
isEndOfStream
in interfaceDeserializationSchema<RowData>
- Parameters:
nextElement
- The element to test for the end-of-stream signal.- Returns:
- True, if the element signals end of stream, false otherwise.
-
getProducedType
public TypeInformation<RowData> getProducedType()
Description copied from interface:ResultTypeQueryable
Gets the data type (as aTypeInformation
) produced by this function or input format.- Specified by:
getProducedType
in interfaceResultTypeQueryable<RowData>
- Returns:
- The data type produced by this function or input format.
-
-