K - The key type to be serialized.V - The value type to be serialized.public class TypeInformationKeyValueSerializationSchema<K,V> extends Object implements KeyedDeserializationSchema<org.apache.flink.api.java.tuple.Tuple2<K,V>>, KeyedSerializationSchema<org.apache.flink.api.java.tuple.Tuple2<K,V>>
| Constructor and Description |
|---|
TypeInformationKeyValueSerializationSchema(Class<K> keyClass,
Class<V> valueClass,
org.apache.flink.api.common.ExecutionConfig config)
Creates a new de-/serialization schema for the given types.
|
TypeInformationKeyValueSerializationSchema(org.apache.flink.api.common.typeinfo.TypeInformation<K> keyTypeInfo,
org.apache.flink.api.common.typeinfo.TypeInformation<V> valueTypeInfo,
org.apache.flink.api.common.ExecutionConfig ec)
Creates a new de-/serialization schema for the given types.
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.flink.api.java.tuple.Tuple2<K,V> |
deserialize(byte[] messageKey,
byte[] message,
String topic,
int partition,
long offset)
Deserializes the byte message.
|
org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.api.java.tuple.Tuple2<K,V>> |
getProducedType() |
boolean |
isEndOfStream(org.apache.flink.api.java.tuple.Tuple2<K,V> nextElement)
This schema never considers an element to signal end-of-stream, so this method returns always false.
|
byte[] |
serializeKey(org.apache.flink.api.java.tuple.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(org.apache.flink.api.java.tuple.Tuple2<K,V> element)
Serializes the value of the incoming element to a byte array
|
public TypeInformationKeyValueSerializationSchema(org.apache.flink.api.common.typeinfo.TypeInformation<K> keyTypeInfo, org.apache.flink.api.common.typeinfo.TypeInformation<V> valueTypeInfo, org.apache.flink.api.common.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, org.apache.flink.api.common.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 org.apache.flink.api.java.tuple.Tuple2<K,V> deserialize(byte[] messageKey, byte[] message, String topic, int partition, long offset) throws IOException
KeyedDeserializationSchemadeserialize in interface KeyedDeserializationSchema<org.apache.flink.api.java.tuple.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 fromoffset - the offset of the message in the original source (for example the Kafka offset) @return The deserialized message as an object.IOExceptionpublic boolean isEndOfStream(org.apache.flink.api.java.tuple.Tuple2<K,V> nextElement)
isEndOfStream in interface KeyedDeserializationSchema<org.apache.flink.api.java.tuple.Tuple2<K,V>>nextElement - The element to test for the end-of-stream signal.public byte[] serializeKey(org.apache.flink.api.java.tuple.Tuple2<K,V> element)
KeyedSerializationSchemaserializeKey in interface KeyedSerializationSchema<org.apache.flink.api.java.tuple.Tuple2<K,V>>element - The incoming element to be serializedpublic byte[] serializeValue(org.apache.flink.api.java.tuple.Tuple2<K,V> element)
KeyedSerializationSchemaserializeValue in interface KeyedSerializationSchema<org.apache.flink.api.java.tuple.Tuple2<K,V>>element - The incoming element to be serializedCopyright © 2014–2016 The Apache Software Foundation. All rights reserved.