@PublicEvolving public interface KafkaRecordDeserializationSchema<T> extends Serializable, ResultTypeQueryable<T>
Modifier and Type | Method and Description |
---|---|
void |
deserialize(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> record,
Collector<T> out)
Deserializes the byte message.
|
static <V> KafkaRecordDeserializationSchema<V> |
of(KafkaDeserializationSchema<V> kafkaDeserializationSchema)
Wraps a legacy
KafkaDeserializationSchema as the deserializer of the ConsumerRecords . |
default void |
open(DeserializationSchema.InitializationContext context)
Initialization method for the schema.
|
static <V> KafkaRecordDeserializationSchema<V> |
valueOnly(Class<? extends org.apache.kafka.common.serialization.Deserializer<V>> valueDeserializerClass)
Wraps a Kafka
Deserializer to a KafkaRecordDeserializationSchema . |
static <V,D extends org.apache.kafka.common.serialization.Deserializer<V>> |
valueOnly(Class<D> valueDeserializerClass,
Map<String,String> config)
Wraps a Kafka
Deserializer to a KafkaRecordDeserializationSchema . |
static <V> KafkaRecordDeserializationSchema<V> |
valueOnly(DeserializationSchema<V> valueDeserializationSchema)
Wraps a
DeserializationSchema as the value deserialization schema of the ConsumerRecords . |
getProducedType
default void open(DeserializationSchema.InitializationContext context) throws Exception
deserialize(org.apache.kafka.clients.consumer.ConsumerRecord<byte[], byte[]>, org.apache.flink.util.Collector<T>)
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
void deserialize(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> record, 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.
record
- The ConsumerRecord to deserialize.out
- The collector to put the resulting messages.IOException
static <V> KafkaRecordDeserializationSchema<V> of(KafkaDeserializationSchema<V> kafkaDeserializationSchema)
KafkaDeserializationSchema
as the deserializer of the ConsumerRecords
.
Note that the KafkaDeserializationSchema.isEndOfStream(Object)
method will no
longer be used to determine the end of the stream.
V
- the return type of the deserialized record.kafkaDeserializationSchema
- the legacy KafkaDeserializationSchema
to use.KafkaRecordDeserializationSchema
that uses the given KafkaDeserializationSchema
to deserialize the ConsumerRecords
.static <V> KafkaRecordDeserializationSchema<V> valueOnly(DeserializationSchema<V> valueDeserializationSchema)
DeserializationSchema
as the value deserialization schema of the ConsumerRecords
. The other fields such as key, headers, timestamp are
ignored.
Note that the DeserializationSchema.isEndOfStream(Object)
method will no longer be
used to determine the end of the stream.
V
- the type of the deserialized record.valueDeserializationSchema
- the DeserializationSchema
used to deserialized the
value of a ConsumerRecord
.KafkaRecordDeserializationSchema
that uses the given DeserializationSchema
to deserialize a ConsumerRecord
from its value.static <V> KafkaRecordDeserializationSchema<V> valueOnly(Class<? extends org.apache.kafka.common.serialization.Deserializer<V>> valueDeserializerClass)
Deserializer
to a KafkaRecordDeserializationSchema
.V
- the value type.valueDeserializerClass
- the deserializer class used to deserialize the value.KafkaRecordDeserializationSchema
that deserialize the value with the given
deserializer.static <V,D extends org.apache.kafka.common.serialization.Deserializer<V>> KafkaRecordDeserializationSchema<V> valueOnly(Class<D> valueDeserializerClass, Map<String,String> config)
Deserializer
to a KafkaRecordDeserializationSchema
.V
- the value type.D
- the type of the deserializer.valueDeserializerClass
- the deserializer class used to deserialize the value.config
- the configuration of the value deserializer. If the deserializer is an
implementation of Configurable
, the configuring logic will be handled by Configurable.configure(Map)
with the given config
,
otherwise Deserializer.configure(Map, boolean)
will be invoked.KafkaRecordDeserializationSchema
that deserialize the value with the given
deserializer.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.