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 Statepublic abstract class AbstractHeapState<K,N,SV,S extends State> extends Object implements InternalKvState<K,N,SV>
State
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 StateTable<K,N,SV> |
stateTable
Map containing the actual key/value pairs.
|
protected TypeSerializer<SV> |
valueSerializer |
Modifier | Constructor and Description |
---|---|
protected |
AbstractHeapState(StateTable<K,N,SV> stateTable,
TypeSerializer<K> keySerializer,
TypeSerializer<SV> valueSerializer,
TypeSerializer<N> namespaceSerializer,
SV defaultValue)
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 SV |
getDefaultValue() |
byte[] |
getSerializedValue(byte[] serializedKeyAndNamespace,
TypeSerializer<K> safeKeySerializer,
TypeSerializer<N> safeNamespaceSerializer,
TypeSerializer<SV> safeValueSerializer)
Returns the serialized value for the given key and 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getKeySerializer, getNamespaceSerializer, getValueSerializer
protected final StateTable<K,N,SV> stateTable
protected N currentNamespace
protected final TypeSerializer<K> keySerializer
protected final TypeSerializer<SV> valueSerializer
protected final TypeSerializer<N> namespaceSerializer
protected AbstractHeapState(StateTable<K,N,SV> stateTable, TypeSerializer<K> keySerializer, TypeSerializer<SV> valueSerializer, TypeSerializer<N> namespaceSerializer, SV defaultValue)
stateTable
- The state table for which this state is associated to.keySerializer
- The serializer for the keys.valueSerializer
- The serializer for the state.namespaceSerializer
- The serializer for the namespace.defaultValue
- The default value for the state.public final void clear()
State
public final void setCurrentNamespace(N namespace)
InternalKvState
setCurrentNamespace
in interface InternalKvState<K,N,SV>
namespace
- The namespace.public byte[] getSerializedValue(byte[] serializedKeyAndNamespace, TypeSerializer<K> safeKeySerializer, TypeSerializer<N> safeNamespaceSerializer, TypeSerializer<SV> safeValueSerializer) throws Exception
InternalKvState
If no value is associated with key and namespace, null
is returned.
TO IMPLEMENTERS: This method is called by multiple threads. Anything stateful (e.g. serializers) should be either duplicated or protected from undesired consequences of concurrent invocations.
getSerializedValue
in interface InternalKvState<K,N,SV>
serializedKeyAndNamespace
- Serialized key and namespacesafeKeySerializer
- A key serializer which is safe to be used even in multi-threaded contextsafeNamespaceSerializer
- A namespace serializer which is safe to be used even in multi-threaded contextsafeValueSerializer
- A value serializer which is safe to be used even in multi-threaded contextnull
if no value is associated with the key and namespace.Exception
- Exceptions during serialization are forwarded@VisibleForTesting public StateTable<K,N,SV> getStateTable()
protected SV getDefaultValue()
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.