public final class KvStateSerializer extends Object
Constructor and Description |
---|
KvStateSerializer() |
Modifier and Type | Method and Description |
---|---|
static <K,N> Tuple2<K,N> |
deserializeKeyAndNamespace(byte[] serializedKeyAndNamespace,
TypeSerializer<K> keySerializer,
TypeSerializer<N> namespaceSerializer)
Deserializes the key and namespace into a
Tuple2 . |
static <T> List<T> |
deserializeList(byte[] serializedValue,
TypeSerializer<T> serializer)
Deserializes all values with the given serializer.
|
static <UK,UV> Map<UK,UV> |
deserializeMap(byte[] serializedValue,
TypeSerializer<UK> keySerializer,
TypeSerializer<UV> valueSerializer)
Deserializes all kv pairs with the given serializer.
|
static <T> T |
deserializeValue(byte[] serializedValue,
TypeSerializer<T> serializer)
Deserializes the value with the given serializer.
|
static <K,N> byte[] |
serializeKeyAndNamespace(K key,
TypeSerializer<K> keySerializer,
N namespace,
TypeSerializer<N> namespaceSerializer)
Serializes the key and namespace into a
ByteBuffer . |
static <UK,UV> byte[] |
serializeMap(Iterable<Map.Entry<UK,UV>> entries,
TypeSerializer<UK> keySerializer,
TypeSerializer<UV> valueSerializer)
Serializes all values of the Iterable with the given serializer.
|
static <T> byte[] |
serializeValue(T value,
TypeSerializer<T> serializer)
Serializes the value with the given serializer.
|
public static <K,N> byte[] serializeKeyAndNamespace(K key, TypeSerializer<K> keySerializer, N namespace, TypeSerializer<N> namespaceSerializer) throws IOException
ByteBuffer
.
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.
K
- Key typeN
- Namespace typekey
- Key to serializekeySerializer
- Serializer for the keynamespace
- Namespace to serializenamespaceSerializer
- Serializer for the namespaceIOException
- Serialization errors are forwardedpublic static <K,N> Tuple2<K,N> deserializeKeyAndNamespace(byte[] serializedKeyAndNamespace, TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer) throws IOException
Tuple2
.K
- Key typeN
- NamespaceserializedKeyAndNamespace
- Serialized key and namespacekeySerializer
- Serializer for the keynamespaceSerializer
- Serializer for the namespaceIOException
- if the deserialization fails for any reasonpublic static <T> byte[] serializeValue(T value, TypeSerializer<T> serializer) throws IOException
T
- Type of the valuevalue
- Value of type T to serializeserializer
- Serializer for Tnull
if value null
IOException
- On failure during serializationpublic static <T> T deserializeValue(byte[] serializedValue, TypeSerializer<T> serializer) throws IOException
T
- Type of the valueserializedValue
- Serialized value of type Tserializer
- Serializer for Tnull
if the serialized value is null
IOException
- On failure during deserializationpublic static <T> List<T> deserializeList(byte[] serializedValue, TypeSerializer<T> serializer) throws IOException
T
- Type of the valueserializedValue
- Serialized value of type List<T>serializer
- Serializer for Tnull
if the serialized value is null
IOException
- On failure during deserializationpublic static <UK,UV> byte[] serializeMap(Iterable<Map.Entry<UK,UV>> entries, TypeSerializer<UK> keySerializer, TypeSerializer<UV> valueSerializer) throws IOException
UK
- Type of the keysUV
- Type of the valuesentries
- Key-value pairs to serializekeySerializer
- Serializer for UKvalueSerializer
- Serializer for UVnull
if values null
or emptyIOException
- On failure during serializationpublic static <UK,UV> Map<UK,UV> deserializeMap(byte[] serializedValue, TypeSerializer<UK> keySerializer, TypeSerializer<UV> valueSerializer) throws IOException
UK
- Type of the keyUV
- Type of the value.serializedValue
- Serialized value of type Map<UK, UV>keySerializer
- Serializer for UKvalueSerializer
- Serializer for UVnull
if the serialized value is null
IOException
- On failure during deserializationCopyright © 2014–2021 The Apache Software Foundation. All rights reserved.