Class AbstractHeapState<K,N,SV>
- java.lang.Object
-
- org.apache.flink.runtime.state.heap.AbstractHeapState<K,N,SV>
-
- Type Parameters:
K- The type of the key.N- The type of the namespace.SV- The type of the values in the state.
- All Implemented Interfaces:
org.apache.flink.api.common.state.State,InternalKvState<K,N,SV>
public abstract class AbstractHeapState<K,N,SV> extends Object implements InternalKvState<K,N,SV>
Base class for partitionedStateimplementations that are backed by a regular heap hash map. The concrete implementations define how the state is checkpointed.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.runtime.state.internal.InternalKvState
InternalKvState.StateIncrementalVisitor<K,N,V>
-
-
Field Summary
Fields Modifier and Type Field Description protected NcurrentNamespaceThe current namespace, which the access methods will refer to.protected org.apache.flink.api.common.typeutils.TypeSerializer<K>keySerializerprotected org.apache.flink.api.common.typeutils.TypeSerializer<N>namespaceSerializerprotected StateTable<K,N,SV>stateTableMap containing the actual key/value pairs.protected org.apache.flink.api.common.typeutils.TypeSerializer<SV>valueSerializer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()protected SVgetDefaultValue()byte[]getSerializedValue(byte[] serializedKeyAndNamespace, org.apache.flink.api.common.typeutils.TypeSerializer<K> safeKeySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<N> safeNamespaceSerializer, org.apache.flink.api.common.typeutils.TypeSerializer<SV> safeValueSerializer)Returns the serialized value for the given key and namespace.InternalKvState.StateIncrementalVisitor<K,N,SV>getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords)Get global visitor of state entries.StateTable<K,N,SV>getStateTable()This should only be used for testing.voidsetCurrentNamespace(N namespace)Sets the current namespace, which will be used when using the state access methods.protected AbstractHeapState<K,N,SV>setDefaultValue(SV defaultValue)protected AbstractHeapState<K,N,SV>setNamespaceSerializer(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)protected AbstractHeapState<K,N,SV>setValueSerializer(org.apache.flink.api.common.typeutils.TypeSerializer<SV> valueSerializer)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.runtime.state.internal.InternalKvState
getKeySerializer, getNamespaceSerializer, getValueSerializer
-
-
-
-
Field Detail
-
stateTable
protected final StateTable<K,N,SV> stateTable
Map containing the actual key/value pairs.
-
currentNamespace
protected N currentNamespace
The current namespace, which the access methods will refer to.
-
keySerializer
protected final org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer
-
valueSerializer
protected org.apache.flink.api.common.typeutils.TypeSerializer<SV> valueSerializer
-
namespaceSerializer
protected org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer
-
-
Method Detail
-
clear
public final void clear()
- Specified by:
clearin interfaceorg.apache.flink.api.common.state.State
-
setCurrentNamespace
public final void setCurrentNamespace(N namespace)
Description copied from interface:InternalKvStateSets the current namespace, which will be used when using the state access methods.- Specified by:
setCurrentNamespacein interfaceInternalKvState<K,N,SV>- Parameters:
namespace- The namespace.
-
getSerializedValue
public byte[] getSerializedValue(byte[] serializedKeyAndNamespace, org.apache.flink.api.common.typeutils.TypeSerializer<K> safeKeySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<N> safeNamespaceSerializer, org.apache.flink.api.common.typeutils.TypeSerializer<SV> safeValueSerializer) throws ExceptionDescription copied from interface:InternalKvStateReturns the serialized value for the given key and namespace.If no value is associated with key and namespace,
nullis 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.
- Specified by:
getSerializedValuein interfaceInternalKvState<K,N,SV>- Parameters:
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 context- Returns:
- Serialized value or
nullif no value is associated with the key and namespace. - Throws:
Exception- Exceptions during serialization are forwarded
-
getStateTable
@VisibleForTesting public StateTable<K,N,SV> getStateTable()
This should only be used for testing.
-
getDefaultValue
protected SV getDefaultValue()
-
setNamespaceSerializer
protected AbstractHeapState<K,N,SV> setNamespaceSerializer(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)
-
setValueSerializer
protected AbstractHeapState<K,N,SV> setValueSerializer(org.apache.flink.api.common.typeutils.TypeSerializer<SV> valueSerializer)
-
setDefaultValue
protected AbstractHeapState<K,N,SV> setDefaultValue(SV defaultValue)
-
getStateIncrementalVisitor
public InternalKvState.StateIncrementalVisitor<K,N,SV> getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords)
Description copied from interface:InternalKvStateGet global visitor of state entries.- Specified by:
getStateIncrementalVisitorin interfaceInternalKvState<K,N,SV>- Parameters:
recommendedMaxNumberOfReturnedRecords- hint to the visitor not to exceed this number of returned records pernextEntriescall, it can still be exceeded by some smaller constant.- Returns:
- global iterator over state entries
-
-