T
- The type created by the deserialization schema.@Public public interface DeserializationSchema<T> extends Serializable, ResultTypeQueryable<T>
In addition, the DeserializationSchema describes the produced type (ResultTypeQueryable.getProducedType()
), which lets Flink create internal serializers and structures to handle the
type.
Note: In most cases, one should start from AbstractDeserializationSchema
, which
takes care of producing the return type information automatically.
A DeserializationSchema must be Serializable
because its instances are often part of
an operator or transformation function.
Modifier and Type | Interface and Description |
---|---|
static interface |
DeserializationSchema.InitializationContext
A contextual information provided for
open(InitializationContext) method. |
Modifier and Type | Method and Description |
---|---|
T |
deserialize(byte[] message)
Deserializes the byte message.
|
default void |
deserialize(byte[] message,
Collector<T> out)
Deserializes the byte message.
|
boolean |
isEndOfStream(T nextElement)
Method to decide whether the element signals the end of the stream.
|
default void |
open(DeserializationSchema.InitializationContext context)
Initialization method for the schema.
|
getProducedType
@PublicEvolving default void open(DeserializationSchema.InitializationContext context) throws Exception
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.
context
- Contextual information that can be used during initialization.Exception
T deserialize(byte[] message) throws IOException
message
- The message, as a byte array.IOException
@PublicEvolving default void deserialize(byte[] message, Collector<T> out) throws IOException
Can output multiple records through the Collector
. Note that number and size of
the produced records should be relatively small. Depending on the source implementation
records can be buffered in memory or collecting records might delay emitting checkpoint
barrier.
message
- The message, as a byte array.out
- The collector to put the resulting messages.IOException
boolean isEndOfStream(T nextElement)
nextElement
- The element to test for the end-of-stream signal.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.