K - The type of the key.N - The type of the namespace.SV - The type of the values in the state.S - The type of StateSD - The type of StateDescriptor for the State Spublic abstract class AbstractHeapState<K,N,SV,S extends State,SD extends StateDescriptor<S,?>> extends Object implements InternalKvState<N>
ListState implementations that are backed by a regular
heap hash map. The concrete implementations define how the state is checkpointed.| Modifier and Type | Field and Description |
|---|---|
protected N |
currentNamespace
The current namespace, which the access methods will refer to.
|
protected TypeSerializer<K> |
keySerializer |
protected TypeSerializer<N> |
namespaceSerializer |
protected SD |
stateDesc
This holds the name of the state and can create an initial default value for the state.
|
protected StateTable<K,N,SV> |
stateTable
Map containing the actual key/value pairs
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractHeapState(SD stateDesc,
StateTable<K,N,SV> stateTable,
TypeSerializer<K> keySerializer,
TypeSerializer<N> namespaceSerializer)
Creates a new key/value state for the given hash map of key/value pairs.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
byte[] |
getSerializedValue(byte[] serializedKeyAndNamespace)
Returns the serialized value for the given key and namespace.
|
byte[] |
getSerializedValue(K key,
N namespace) |
StateTable<K,N,SV> |
getStateTable()
This should only be used for testing.
|
void |
setCurrentNamespace(N namespace)
Sets the current namespace, which will be used when using the state access methods.
|
protected final StateTable<K,N,SV> stateTable
protected final SD extends StateDescriptor<S,?> stateDesc
protected N currentNamespace
protected final TypeSerializer<K> keySerializer
protected final TypeSerializer<N> namespaceSerializer
protected AbstractHeapState(SD stateDesc, StateTable<K,N,SV> stateTable, TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer)
stateDesc - The state identifier for the state. This contains name
and can create a default state value.stateTable - The state tab;e to use in this kev/value state. May contain initial state.public final void setCurrentNamespace(N namespace)
InternalKvStatesetCurrentNamespace in interface InternalKvState<N>namespace - The namespace.public byte[] getSerializedValue(byte[] serializedKeyAndNamespace)
throws Exception
InternalKvStateIf no value is associated with key and namespace, null
is returned.
getSerializedValue in interface InternalKvState<N>serializedKeyAndNamespace - Serialized key and namespacenull if no value is associated with the key and namespace.Exception - Exceptions during serialization are forwardedpublic byte[] getSerializedValue(K key, N namespace) throws Exception
Exception@VisibleForTesting public StateTable<K,N,SV> getStateTable()
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.