Class KvStateSerializer
- java.lang.Object
-
- org.apache.flink.queryablestate.client.state.serialization.KvStateSerializer
-
public final class KvStateSerializer extends Object
Serialization and deserialization the different state types and namespaces.
-
-
Constructor Summary
Constructors Constructor Description KvStateSerializer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,N>
org.apache.flink.api.java.tuple.Tuple2<K,N>deserializeKeyAndNamespace(byte[] serializedKeyAndNamespace, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)Deserializes the key and namespace into aTuple2.static <T> List<T>deserializeList(byte[] serializedValue, org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer)Deserializes all values with the given serializer.static <UK,UV>
Map<UK,UV>deserializeMap(byte[] serializedValue, org.apache.flink.api.common.typeutils.TypeSerializer<UK> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<UV> valueSerializer)Deserializes all kv pairs with the given serializer.static <T> TdeserializeValue(byte[] serializedValue, org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer)Deserializes the value with the given serializer.static <K,N>
byte[]serializeKeyAndNamespace(K key, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, N namespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)Serializes the key and namespace into aByteBuffer.static <UK,UV>
byte[]serializeMap(Iterable<Map.Entry<UK,UV>> entries, org.apache.flink.api.common.typeutils.TypeSerializer<UK> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<UV> valueSerializer)Serializes all values of the Iterable with the given serializer.static <T> byte[]serializeValue(T value, org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer)Serializes the value with the given serializer.
-
-
-
Method Detail
-
serializeKeyAndNamespace
public static <K,N> byte[] serializeKeyAndNamespace(K key, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, N namespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer) throws IOExceptionSerializes the key and namespace into aByteBuffer.The serialized format matches the RocksDB state backend key format, i.e. the key and namespace don't have to be deserialized for RocksDB lookups.
- Type Parameters:
K- Key typeN- Namespace type- Parameters:
key- Key to serializekeySerializer- Serializer for the keynamespace- Namespace to serializenamespaceSerializer- Serializer for the namespace- Returns:
- Buffer holding the serialized key and namespace
- Throws:
IOException- Serialization errors are forwarded
-
deserializeKeyAndNamespace
public static <K,N> org.apache.flink.api.java.tuple.Tuple2<K,N> deserializeKeyAndNamespace(byte[] serializedKeyAndNamespace, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer) throws IOExceptionDeserializes the key and namespace into aTuple2.- Type Parameters:
K- Key typeN- Namespace- Parameters:
serializedKeyAndNamespace- Serialized key and namespacekeySerializer- Serializer for the keynamespaceSerializer- Serializer for the namespace- Returns:
- Tuple2 holding deserialized key and namespace
- Throws:
IOException- if the deserialization fails for any reason
-
serializeValue
public static <T> byte[] serializeValue(T value, org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer) throws IOExceptionSerializes the value with the given serializer.- Type Parameters:
T- Type of the value- Parameters:
value- Value of type T to serializeserializer- Serializer for T- Returns:
- Serialized value or
nullif valuenull - Throws:
IOException- On failure during serialization
-
deserializeValue
public static <T> T deserializeValue(byte[] serializedValue, org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer) throws IOExceptionDeserializes the value with the given serializer.- Type Parameters:
T- Type of the value- Parameters:
serializedValue- Serialized value of type Tserializer- Serializer for T- Returns:
- Deserialized value or
nullif the serialized value isnull - Throws:
IOException- On failure during deserialization
-
deserializeList
public static <T> List<T> deserializeList(byte[] serializedValue, org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer) throws IOException
Deserializes all values with the given serializer.- Type Parameters:
T- Type of the value- Parameters:
serializedValue- Serialized value of type List<T>serializer- Serializer for T- Returns:
- Deserialized list or
nullif the serialized value isnull - Throws:
IOException- On failure during deserialization
-
serializeMap
public static <UK,UV> byte[] serializeMap(Iterable<Map.Entry<UK,UV>> entries, org.apache.flink.api.common.typeutils.TypeSerializer<UK> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<UV> valueSerializer) throws IOException
Serializes all values of the Iterable with the given serializer.- Type Parameters:
UK- Type of the keysUV- Type of the values- Parameters:
entries- Key-value pairs to serializekeySerializer- Serializer for UKvalueSerializer- Serializer for UV- Returns:
- Serialized values or
nullif valuesnullor empty - Throws:
IOException- On failure during serialization
-
deserializeMap
public static <UK,UV> Map<UK,UV> deserializeMap(byte[] serializedValue, org.apache.flink.api.common.typeutils.TypeSerializer<UK> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<UV> valueSerializer) throws IOException
Deserializes all kv pairs with the given serializer.- Type Parameters:
UK- Type of the keyUV- Type of the value.- Parameters:
serializedValue- Serialized value of type Map<UK, UV>keySerializer- Serializer for UKvalueSerializer- Serializer for UV- Returns:
- Deserialized map or
nullif the serialized value isnull - Throws:
IOException- On failure during deserialization
-
-