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 KvState<N>, State
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 KeyedStateBackend<K> |
backend |
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(KeyedStateBackend<K> backend,
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()
Removes the value mapped under the current key.
|
protected <MK,MV> Map<MK,MV> |
createNewMap()
Creates a new map for use in Heap based state.
|
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 KeyedStateBackend<K> backend
protected final TypeSerializer<K> keySerializer
protected final TypeSerializer<N> namespaceSerializer
protected AbstractHeapState(KeyedStateBackend<K> backend, SD stateDesc, StateTable<K,N,SV> stateTable, TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer)
backend
- The state backend backing that created this state.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 clear()
State
public final void setCurrentNamespace(N namespace)
KvState
setCurrentNamespace
in interface KvState<N>
namespace
- The namespace.public byte[] getSerializedValue(byte[] serializedKeyAndNamespace) throws Exception
KvState
If no value is associated with key and namespace, null
is returned.
getSerializedValue
in interface KvState<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
protected <MK,MV> Map<MK,MV> createNewMap()
If the state queryable (StateDescriptor.isQueryable()
, this
will create a concurrent hash map instead of a regular one.
public StateTable<K,N,SV> getStateTable()
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.