K
- The key type to be serialized.V
- The value type to be serialized.@PublicEvolving public class TypeInformationKeyValueSerializationSchema<K,V> extends Object implements KafkaDeserializationSchema<Tuple2<K,V>>, KeyedSerializationSchema<Tuple2<K,V>>
Constructor and Description |
---|
TypeInformationKeyValueSerializationSchema(Class<K> keyClass,
Class<V> valueClass,
ExecutionConfig config)
Creates a new de-/serialization schema for the given types.
|
TypeInformationKeyValueSerializationSchema(TypeInformation<K> keyTypeInfo,
TypeInformation<V> valueTypeInfo,
ExecutionConfig ec)
Creates a new de-/serialization schema for the given types.
|
Modifier and Type | Method and Description |
---|---|
Tuple2<K,V> |
deserialize(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> record)
Deserializes the Kafka record.
|
TypeInformation<Tuple2<K,V>> |
getProducedType()
Gets the data type (as a
TypeInformation ) produced by this function or input format. |
String |
getTargetTopic(Tuple2<K,V> element)
Optional method to determine the target topic for the element.
|
boolean |
isEndOfStream(Tuple2<K,V> nextElement)
This schema never considers an element to signal end-of-stream, so this method returns always
false.
|
byte[] |
serializeKey(Tuple2<K,V> element)
Serializes the key of the incoming element to a byte array This method might return null if
no key is available.
|
byte[] |
serializeValue(Tuple2<K,V> element)
Serializes the value of the incoming element to a byte array.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
deserialize, open
public TypeInformationKeyValueSerializationSchema(TypeInformation<K> keyTypeInfo, TypeInformation<V> valueTypeInfo, ExecutionConfig ec)
keyTypeInfo
- The type information for the key type de-/serialized by this schema.valueTypeInfo
- The type information for the value type de-/serialized by this schema.ec
- The execution config, which is used to parametrize the type serializers.public TypeInformationKeyValueSerializationSchema(Class<K> keyClass, Class<V> valueClass, ExecutionConfig config)
If the types are parametrized and cannot be fully defined via classes, use the constructor
that accepts TypeInformation
instead.
keyClass
- The class of the key de-/serialized by this schema.valueClass
- The class of the value de-/serialized by this schema.config
- The execution config, which is used to parametrize the type serializers.public Tuple2<K,V> deserialize(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> record) throws Exception
KafkaDeserializationSchema
deserialize
in interface KafkaDeserializationSchema<Tuple2<K,V>>
record
- Kafka record to be deserialized.Exception
public boolean isEndOfStream(Tuple2<K,V> nextElement)
isEndOfStream
in interface KafkaDeserializationSchema<Tuple2<K,V>>
nextElement
- The element to test for the end-of-stream signal.public byte[] serializeKey(Tuple2<K,V> element)
KeyedSerializationSchema
serializeKey
in interface KeyedSerializationSchema<Tuple2<K,V>>
element
- The incoming element to be serializedpublic byte[] serializeValue(Tuple2<K,V> element)
KeyedSerializationSchema
serializeValue
in interface KeyedSerializationSchema<Tuple2<K,V>>
element
- The incoming element to be serializedpublic String getTargetTopic(Tuple2<K,V> element)
KeyedSerializationSchema
getTargetTopic
in interface KeyedSerializationSchema<Tuple2<K,V>>
element
- Incoming element to determine the target topic frompublic TypeInformation<Tuple2<K,V>> getProducedType()
ResultTypeQueryable
TypeInformation
) produced by this function or input format.getProducedType
in interface ResultTypeQueryable<Tuple2<K,V>>
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.