K
- The key type to be serialized.V
- The value type to be serialized.@Internal public class TypeInformationKeyValueSerializationSchema<K,V> extends Object implements KeyedDeserializationSchema<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(byte[] messageKey,
byte[] message,
String topic,
int partition,
long offset)
Deserializes the byte message.
|
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.
|
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(byte[] messageKey, byte[] message, String topic, int partition, long offset) throws IOException
KeyedDeserializationSchema
deserialize
in interface KeyedDeserializationSchema<Tuple2<K,V>>
messageKey
- the key as a byte array (null if no key has been set).message
- The message, as a byte array (null if the message was empty or deleted).partition
- The partition the message has originated from.offset
- the offset of the message in the original source (for example the Kafka offset).IOException
public boolean isEndOfStream(Tuple2<K,V> nextElement)
isEndOfStream
in interface KeyedDeserializationSchema<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–2019 The Apache Software Foundation. All rights reserved.