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 SBackend
- The type of the backend that snapshots this key/value state.public abstract class AbstractHeapState<K,N,SV,S extends State,SD extends StateDescriptor<S,?>,Backend extends AbstractStateBackend> extends Object implements KvState<K,N,S,SD,Backend>, 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 K |
currentKey
The current key, which the next value methods will refer to
|
protected N |
currentNamespace
The current namespace, which the access methods will refer to.
|
protected Map<K,SV> |
currentNSState
Cache the state map for the current key.
|
protected TypeSerializer<K> |
keySerializer
The serializer for the keys
|
protected TypeSerializer<N> |
namespaceSerializer
The serializer for the namespace
|
protected HashMap<N,Map<K,SV>> |
state
Map containing the actual key/value pairs
|
protected SD |
stateDesc
This holds the name of the state and can create an initial default value for the state.
|
protected TypeSerializer<SV> |
stateSerializer
Serializer for the state value.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractHeapState(TypeSerializer<K> keySerializer,
TypeSerializer<N> namespaceSerializer,
TypeSerializer<SV> stateSerializer,
SD stateDesc)
Creates a new empty key/value state.
|
protected |
AbstractHeapState(TypeSerializer<K> keySerializer,
TypeSerializer<N> namespaceSerializer,
TypeSerializer<SV> stateSerializer,
SD stateDesc,
HashMap<N,Map<K,SV>> state)
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.
|
void |
dispose()
Disposes the key/value state, releasing all occupied resources.
|
TypeSerializer<K> |
getKeySerializer()
Gets the serializer for the keys.
|
TypeSerializer<N> |
getNamespaceSerializer()
Gets the serializer for the namespace.
|
void |
setCurrentKey(K currentKey)
Sets the current key, which will be used when using the state access methods.
|
void |
setCurrentNamespace(N namespace)
Sets the current namespace, which will be used when using the state access methods.
|
protected int |
size()
Returns the number of all state pairs in this state, across namespaces.
|
protected final TypeSerializer<SV> stateSerializer
protected final TypeSerializer<K> keySerializer
protected final TypeSerializer<N> namespaceSerializer
protected final SD extends StateDescriptor<S,?> stateDesc
protected K currentKey
protected N currentNamespace
protected AbstractHeapState(TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer, TypeSerializer<SV> stateSerializer, SD stateDesc)
keySerializer
- The serializer for the keys.namespaceSerializer
- The serializer for the namespace.stateDesc
- The state identifier for the state. This contains name
and can create a default state value.protected AbstractHeapState(TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer, TypeSerializer<SV> stateSerializer, SD stateDesc, HashMap<N,Map<K,SV>> state)
keySerializer
- The serializer for the keys.stateDesc
- The state identifier for the state. This contains name
and can create a default state value.state
- The state map to use in this kev/value state. May contain initial state.public final void clear()
State
public final void setCurrentKey(K currentKey)
KvState
setCurrentKey
in interface KvState<K,N,S extends State,SD extends StateDescriptor<S,?>,Backend extends AbstractStateBackend>
currentKey
- The key.public final void setCurrentNamespace(N namespace)
KvState
setCurrentNamespace
in interface KvState<K,N,S extends State,SD extends StateDescriptor<S,?>,Backend extends AbstractStateBackend>
namespace
- The namespace.protected final int size()
public void dispose()
KvState
public final TypeSerializer<K> getKeySerializer()
public final TypeSerializer<N> getNamespaceSerializer()
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.