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,
org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
ClassLoader userCodeClassLoader,
int numberOfKeyGroups,
KeyGroupRange keyGroupRange,
boolean asynchronousSnapshots,
org.apache.flink.api.common.ExecutionConfig executionConfig,
LocalRecoveryConfig localRecoveryConfig) |
| Modifier and Type | Method and Description |
|---|---|
<N,S extends org.apache.flink.api.common.state.State,T> |
applyToAllKeys(N namespace,
org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,T> stateDescriptor,
KeyedStateFunction<K,S> function)
Applies the provided
KeyedStateFunction to the state with the provided
StateDescriptor of all the currently active keys. |
<N,T,ACC,R> |
createAggregatingState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.AggregatingStateDescriptor<T,ACC,R> stateDesc)
Creates and returns a new
AggregatingState. |
<N,T,ACC> InternalFoldingState<K,N,T,ACC> |
createFoldingState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.FoldingStateDescriptor<T,ACC> stateDesc)
Creates and returns a new
FoldingState. |
<N,T> InternalListState<K,N,T> |
createListState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.ListStateDescriptor<T> stateDesc)
Creates and returns a new
ListState. |
protected <N,UK,UV> InternalMapState<K,N,UK,UV> |
createMapState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.MapStateDescriptor<UK,UV> stateDesc)
Creates and returns a new
MapState. |
<N,T> InternalReducingState<K,N,T> |
createReducingState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.ReducingStateDescriptor<T> stateDesc)
Creates and returns a new
ReducingState. |
<N,V> InternalValueState<K,N,V> |
createValueState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.ValueStateDescriptor<V> stateDesc)
Creates and returns a new
ValueState. |
<N> java.util.stream.Stream<K> |
getKeys(String state,
N namespace) |
LocalRecoveryConfig |
getLocalRecoveryConfig() |
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<SnapshotResult<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, setCurrentKeypublic HeapKeyedStateBackend(TaskKvStateRegistry kvStateRegistry, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, ClassLoader userCodeClassLoader, int numberOfKeyGroups, KeyGroupRange keyGroupRange, boolean asynchronousSnapshots, org.apache.flink.api.common.ExecutionConfig executionConfig, LocalRecoveryConfig localRecoveryConfig)
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<K,N,V> createValueState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.ValueStateDescriptor<V> stateDesc) throws Exception
AbstractKeyedStateBackendValueState.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.Exceptionpublic <N,T> InternalListState<K,N,T> createListState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.ListStateDescriptor<T> stateDesc) throws Exception
AbstractKeyedStateBackendListState.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.Exceptionpublic <N,T> InternalReducingState<K,N,T> createReducingState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.ReducingStateDescriptor<T> stateDesc) throws Exception
AbstractKeyedStateBackendReducingState.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.Exceptionpublic <N,T,ACC,R> InternalAggregatingState<K,N,T,ACC,R> createAggregatingState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.AggregatingStateDescriptor<T,ACC,R> stateDesc) throws Exception
AbstractKeyedStateBackendAggregatingState.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.Exceptionpublic <N,T,ACC> InternalFoldingState<K,N,T,ACC> createFoldingState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.FoldingStateDescriptor<T,ACC> stateDesc) throws Exception
AbstractKeyedStateBackendFoldingState.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.Exceptionprotected <N,UK,UV> InternalMapState<K,N,UK,UV> createMapState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.MapStateDescriptor<UK,UV> stateDesc) throws Exception
AbstractKeyedStateBackendMapState.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.Exceptionpublic RunnableFuture<SnapshotResult<KeyedStateHandle>> snapshot(long checkpointId, long timestamp, CheckpointStreamFactory streamFactory, CheckpointOptions checkpointOptions)
SnapshotableCheckpointStreamFactory 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.public void restore(Collection<KeyedStateHandle> restoredState) throws Exception
SnapshotablerestoredState - the old state to restore.Exceptionpublic void notifyCheckpointComplete(long checkpointId)
CheckpointListenercheckpointId - The ID of the checkpoint that has been completed.public <N,S extends org.apache.flink.api.common.state.State,T> void applyToAllKeys(N namespace,
org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,T> stateDescriptor,
KeyedStateFunction<K,S> function)
throws Exception
KeyedStateBackendKeyedStateFunction to the state with the provided
StateDescriptor of all the currently active keys.applyToAllKeys in interface KeyedStateBackend<K>applyToAllKeys in class AbstractKeyedStateBackend<K>N - The type of the namespace.S - The type of the state.namespace - the namespace of the state.namespaceSerializer - the serializer for the namespace.stateDescriptor - the descriptor of the state to which the function is going to be applied.function - the function to be applied to the keyed state.ExceptionKeyedStateBackend@VisibleForTesting public int numStateEntries()
numStateEntries in class AbstractKeyedStateBackend<K>@VisibleForTesting public int numStateEntries(Object namespace)
public boolean supportsAsynchronousSnapshots()
supportsAsynchronousSnapshots in class AbstractKeyedStateBackend<K>@VisibleForTesting public LocalRecoveryConfig getLocalRecoveryConfig()
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.