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, keyGroupRange, keySerializer, keyValueStatesByName, kvStateRegistry, numberOfKeyGroups, userCodeClassLoader
Constructor and Description |
---|
HeapKeyedStateBackend(TaskKvStateRegistry kvStateRegistry,
TypeSerializer<K> keySerializer,
ClassLoader userCodeClassLoader,
int numberOfKeyGroups,
KeyGroupRange keyGroupRange) |
Modifier and Type | Method and Description |
---|---|
protected <N,T,ACC> FoldingState<T,ACC> |
createFoldingState(TypeSerializer<N> namespaceSerializer,
FoldingStateDescriptor<T,ACC> stateDesc)
Creates and returns a new
FoldingState . |
<N,T> ListState<T> |
createListState(TypeSerializer<N> namespaceSerializer,
ListStateDescriptor<T> stateDesc)
Creates and returns a new
ListState . |
<N,T> ReducingState<T> |
createReducingState(TypeSerializer<N> namespaceSerializer,
ReducingStateDescriptor<T> stateDesc)
Creates and returns a new
ReducingState . |
<N,V> ValueState<V> |
createValueState(TypeSerializer<N> namespaceSerializer,
ValueStateDescriptor<V> stateDesc)
Creates and returns a new
ValueState . |
int |
numStateEntries()
Returns the total number of state entries across all keys/namespaces.
|
<N> int |
numStateEntries(N namespace)
Returns the total number of state entries across all keys for the given namespace.
|
void |
restore(Collection<KeyGroupsStateHandle> restoredState)
Restores state that was previously snapshotted from the provided parameters.
|
RunnableFuture<KeyGroupsStateHandle> |
snapshot(long checkpointId,
long timestamp,
CheckpointStreamFactory streamFactory)
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. |
String |
toString() |
close, dispose, getCurrentKey, getCurrentKeyGroupIndex, getKeyGroupRange, getKeySerializer, getNumberOfKeyGroups, getPartitionedState, mergePartitionedStates, setCurrentKey
public HeapKeyedStateBackend(TaskKvStateRegistry kvStateRegistry, TypeSerializer<K> keySerializer, ClassLoader userCodeClassLoader, int numberOfKeyGroups, KeyGroupRange keyGroupRange)
public <N,V> ValueState<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> ListState<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> ReducingState<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
protected <N,T,ACC> FoldingState<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 state *namespaceSerializer
- TypeSerializer for the state namespace.stateDesc
- The StateDescriptor
that contains the name of the state.Exception
public RunnableFuture<KeyGroupsStateHandle> snapshot(long checkpointId, long timestamp, CheckpointStreamFactory streamFactory) 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.StateObject
.Exception
public void restore(Collection<KeyGroupsStateHandle> restoredState) throws Exception
Snapshotable
restoredState
- the old state to restore.Exception
@VisibleForTesting public int numStateEntries()
@VisibleForTesting public <N> int numStateEntries(N namespace)
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.