K
- The key by which state is keyed.public class HeapKeyedStateBackend<K> extends AbstractKeyedStateBackend<K>
AbstractKeyedStateBackend
that keeps state on the Java Heap and will serialize state to
streams provided by a CheckpointStreamFactory
upon
checkpointing.cancelStreamRegistry, currentKey, keyGroupCompressionDecorator, keyGroupRange, keySerializer, keyValueStatesByName, kvStateRegistry, numberOfKeyGroups, userCodeClassLoader
Constructor and Description |
---|
HeapKeyedStateBackend(TaskKvStateRegistry kvStateRegistry,
TypeSerializer<K> keySerializer,
ClassLoader userCodeClassLoader,
int numberOfKeyGroups,
KeyGroupRange keyGroupRange,
boolean asynchronousSnapshots,
ExecutionConfig executionConfig) |
Modifier and Type | Method and Description |
---|---|
<N,T,ACC,R> |
createAggregatingState(TypeSerializer<N> namespaceSerializer,
AggregatingStateDescriptor<T,ACC,R> stateDesc)
Creates and returns a new
AggregatingState . |
<N,T,ACC> InternalFoldingState<N,T,ACC> |
createFoldingState(TypeSerializer<N> namespaceSerializer,
FoldingStateDescriptor<T,ACC> stateDesc)
Creates and returns a new
FoldingState . |
<N,T> InternalListState<N,T> |
createListState(TypeSerializer<N> namespaceSerializer,
ListStateDescriptor<T> stateDesc)
Creates and returns a new
ListState . |
<N,UK,UV> InternalMapState<N,UK,UV> |
createMapState(TypeSerializer<N> namespaceSerializer,
MapStateDescriptor<UK,UV> stateDesc)
Creates and returns a new
MapState . |
<N,T> InternalReducingState<N,T> |
createReducingState(TypeSerializer<N> namespaceSerializer,
ReducingStateDescriptor<T> stateDesc)
Creates and returns a new
ReducingState . |
<N,V> InternalValueState<N,V> |
createValueState(TypeSerializer<N> namespaceSerializer,
ValueStateDescriptor<V> stateDesc)
Creates and returns a new
ValueState . |
<N> java.util.stream.Stream<K> |
getKeys(String state,
N namespace) |
<N,V> StateTable<K,N,V> |
newStateTable(RegisteredKeyedBackendStateMetaInfo<N,V> newMetaInfo) |
void |
notifyCheckpointComplete(long checkpointId)
This method is called as a notification once a distributed checkpoint has been completed.
|
int |
numStateEntries()
Returns the total number of state entries across all keys/namespaces.
|
int |
numStateEntries(Object namespace)
Returns the total number of state entries across all keys for the given namespace.
|
void |
restore(Collection<KeyedStateHandle> restoredState)
Restores state that was previously snapshotted from the provided parameters.
|
RunnableFuture<KeyedStateHandle> |
snapshot(long checkpointId,
long timestamp,
CheckpointStreamFactory streamFactory,
CheckpointOptions checkpointOptions)
Operation that writes a snapshot into a stream that is provided by the given
CheckpointStreamFactory and
returns a @RunnableFuture that gives a state handle to the snapshot. |
boolean |
supportsAsynchronousSnapshots() |
String |
toString() |
close, dispose, getCurrentKey, getCurrentKeyGroupIndex, getKeyGroupCompressionDecorator, getKeyGroupRange, getKeySerializer, getNumberOfKeyGroups, getOrCreateKeyedState, getPartitionedState, setCurrentKey
public HeapKeyedStateBackend(TaskKvStateRegistry kvStateRegistry, TypeSerializer<K> keySerializer, ClassLoader userCodeClassLoader, int numberOfKeyGroups, KeyGroupRange keyGroupRange, boolean asynchronousSnapshots, ExecutionConfig executionConfig)
public <N> java.util.stream.Stream<K> getKeys(String state, N namespace)
state
- State variable for which existing keys will be returned.namespace
- Namespace for which existing keys will be returned.public <N,V> InternalValueState<N,V> createValueState(TypeSerializer<N> namespaceSerializer, ValueStateDescriptor<V> stateDesc) throws Exception
AbstractKeyedStateBackend
ValueState
.createValueState
in class AbstractKeyedStateBackend<K>
N
- The type of the namespace.V
- The type of the value that the ValueState
can store.namespaceSerializer
- TypeSerializer for the state namespace.stateDesc
- The StateDescriptor
that contains the name of the state.Exception
public <N,T> InternalListState<N,T> createListState(TypeSerializer<N> namespaceSerializer, ListStateDescriptor<T> stateDesc) throws Exception
AbstractKeyedStateBackend
ListState
.createListState
in class AbstractKeyedStateBackend<K>
N
- The type of the namespace.T
- The type of the values that the ListState
can store.namespaceSerializer
- TypeSerializer for the state namespace.stateDesc
- The StateDescriptor
that contains the name of the state.Exception
public <N,T> InternalReducingState<N,T> createReducingState(TypeSerializer<N> namespaceSerializer, ReducingStateDescriptor<T> stateDesc) throws Exception
AbstractKeyedStateBackend
ReducingState
.createReducingState
in class AbstractKeyedStateBackend<K>
N
- The type of the namespace.T
- The type of the values that the ListState
can store.namespaceSerializer
- TypeSerializer for the state namespace.stateDesc
- The StateDescriptor
that contains the name of the state.Exception
public <N,T,ACC,R> InternalAggregatingState<N,T,R> createAggregatingState(TypeSerializer<N> namespaceSerializer, AggregatingStateDescriptor<T,ACC,R> stateDesc) throws Exception
AbstractKeyedStateBackend
AggregatingState
.createAggregatingState
in class AbstractKeyedStateBackend<K>
N
- The type of the namespace.T
- The type of the values that the ListState
can store.namespaceSerializer
- TypeSerializer for the state namespace.stateDesc
- The StateDescriptor
that contains the name of the state.Exception
public <N,T,ACC> InternalFoldingState<N,T,ACC> createFoldingState(TypeSerializer<N> namespaceSerializer, FoldingStateDescriptor<T,ACC> stateDesc) throws Exception
AbstractKeyedStateBackend
FoldingState
.createFoldingState
in class AbstractKeyedStateBackend<K>
N
- The type of the namespace.T
- Type of the values folded into the stateACC
- Type of the value in the statenamespaceSerializer
- TypeSerializer for the state namespace.stateDesc
- The StateDescriptor
that contains the name of the state.Exception
public <N,UK,UV> InternalMapState<N,UK,UV> createMapState(TypeSerializer<N> namespaceSerializer, MapStateDescriptor<UK,UV> stateDesc) throws Exception
AbstractKeyedStateBackend
MapState
.createMapState
in class AbstractKeyedStateBackend<K>
N
- The type of the namespace.UK
- Type of the keys in the stateUV
- Type of the values in the state *namespaceSerializer
- TypeSerializer for the state namespace.stateDesc
- The StateDescriptor
that contains the name of the state.Exception
public RunnableFuture<KeyedStateHandle> snapshot(long checkpointId, long timestamp, CheckpointStreamFactory streamFactory, CheckpointOptions checkpointOptions) throws Exception
Snapshotable
CheckpointStreamFactory
and
returns a @RunnableFuture
that gives a state handle to the snapshot. It is up to the implementation if
the operation is performed synchronous or asynchronous. In the later case, the returned Runnable must be executed
first before obtaining the handle.checkpointId
- The ID of the checkpoint.timestamp
- The timestamp of the checkpoint.streamFactory
- The factory that we can use for writing our state to streams.checkpointOptions
- Options for how to perform this checkpoint.StateObject
.Exception
public void restore(Collection<KeyedStateHandle> restoredState) throws Exception
Snapshotable
restoredState
- the old state to restore.Exception
public void notifyCheckpointComplete(long checkpointId)
CheckpointListener
checkpointId
- The ID of the checkpoint that has been completed.@VisibleForTesting public int numStateEntries()
numStateEntries
in class AbstractKeyedStateBackend<K>
@VisibleForTesting public int numStateEntries(Object namespace)
public <N,V> StateTable<K,N,V> newStateTable(RegisteredKeyedBackendStateMetaInfo<N,V> newMetaInfo)
public boolean supportsAsynchronousSnapshots()
supportsAsynchronousSnapshots
in class AbstractKeyedStateBackend<K>
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.