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.AbstractKeyedStateBackend.PartitionStateFactoryKeyedStateBackend.KeySelectionListener<K>cancelStreamRegistry, keyContext, keyGroupCompressionDecorator, keyGroupRange, keySerializer, kvStateRegistry, latencyTrackingStateConfig, numberOfKeyGroups, ttlTimeProvider, userCodeClassLoader| Constructor and Description |
|---|
HeapKeyedStateBackend(TaskKvStateRegistry kvStateRegistry,
org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
ClassLoader userCodeClassLoader,
org.apache.flink.api.common.ExecutionConfig executionConfig,
TtlTimeProvider ttlTimeProvider,
LatencyTrackingStateConfig latencyTrackingStateConfig,
org.apache.flink.core.fs.CloseableRegistry cancelStreamRegistry,
StreamCompressionDecorator keyGroupCompressionDecorator,
Map<String,StateTable<K,?,?>> registeredKVStates,
Map<String,HeapPriorityQueueSnapshotRestoreWrapper<?>> registeredPQStates,
LocalRecoveryConfig localRecoveryConfig,
HeapPriorityQueueSetFactory priorityQueueSetFactory,
org.apache.flink.runtime.state.heap.HeapSnapshotStrategy<K> checkpointStrategy,
SnapshotExecutionType snapshotExecutionType,
org.apache.flink.runtime.state.heap.StateTableFactory<K> stateTableFactory,
InternalKeyContext<K> keyContext) |
| 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,
AbstractKeyedStateBackend.PartitionStateFactory partitionStateFactory) |
<T extends HeapPriorityQueueElement & PriorityComparable<? super T> & Keyed<?>> |
create(String stateName,
org.apache.flink.api.common.typeutils.TypeSerializer<T> byteOrderedElementSerializer)
Creates a
KeyGroupedInternalPriorityQueue. |
<N,SV,SEV,S extends org.apache.flink.api.common.state.State,IS extends S> |
createInternalState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,SV> stateDesc,
StateSnapshotTransformer.StateSnapshotTransformFactory<SEV> snapshotTransformFactory)
Creates and returns a new
InternalKvState. |
<N> java.util.stream.Stream<K> |
getKeys(String state,
N namespace) |
<N> java.util.stream.Stream<org.apache.flink.api.java.tuple.Tuple2<K,N>> |
getKeysAndNamespaces(String state) |
LocalRecoveryConfig |
getLocalRecoveryConfig() |
void |
notifyCheckpointAborted(long checkpointId) |
void |
notifyCheckpointComplete(long checkpointId) |
int |
numKeyValueStateEntries()
Returns the total number of state entries across all keys/namespaces.
|
int |
numKeyValueStateEntries(Object namespace)
Returns the total number of state entries across all keys for the given namespace.
|
SavepointResources<K> |
savepoint()
Returns a
SavepointResources that can be used by SavepointSnapshotStrategy to
write out a savepoint in the common/unified format. |
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. |
String |
toString() |
applyToAllKeys, close, deregisterKeySelectionListener, dispose, getCurrentKey, getCurrentKeyGroupIndex, getKeyContext, getKeyGroupCompressionDecorator, getKeyGroupRange, getKeySerializer, getLatencyTrackingStateConfig, getNumberOfKeyGroups, getOrCreateKeyedState, getPartitionedState, numKeyValueStatesByName, publishQueryableStateIfEnabled, registerKeySelectionListener, requiresLegacySynchronousTimerSnapshots, setCurrentKey, setCurrentKeyGroupIndexclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetDelegatedKeyedStateBackendisStateImmutableInStateBackendcreateInternalStatepublic HeapKeyedStateBackend(TaskKvStateRegistry kvStateRegistry, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, ClassLoader userCodeClassLoader, org.apache.flink.api.common.ExecutionConfig executionConfig, TtlTimeProvider ttlTimeProvider, LatencyTrackingStateConfig latencyTrackingStateConfig, org.apache.flink.core.fs.CloseableRegistry cancelStreamRegistry, StreamCompressionDecorator keyGroupCompressionDecorator, Map<String,StateTable<K,?,?>> registeredKVStates, Map<String,HeapPriorityQueueSnapshotRestoreWrapper<?>> registeredPQStates, LocalRecoveryConfig localRecoveryConfig, HeapPriorityQueueSetFactory priorityQueueSetFactory, org.apache.flink.runtime.state.heap.HeapSnapshotStrategy<K> checkpointStrategy, SnapshotExecutionType snapshotExecutionType, org.apache.flink.runtime.state.heap.StateTableFactory<K> stateTableFactory, InternalKeyContext<K> keyContext)
@Nonnull public <T extends HeapPriorityQueueElement & PriorityComparable<? super T> & Keyed<?>> KeyGroupedInternalPriorityQueue<T> create(@Nonnull String stateName, @Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<T> byteOrderedElementSerializer)
PriorityQueueSetFactoryKeyGroupedInternalPriorityQueue.T - type of the stored elements.stateName - unique name for associated with this queue.byteOrderedElementSerializer - a serializer that with a format that is lexicographically
ordered in alignment with elementPriorityComparator.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> java.util.stream.Stream<org.apache.flink.api.java.tuple.Tuple2<K,N>> getKeysAndNamespaces(String state)
state - State variable for which existing keys will be returned.@Nonnull public <N,SV,SEV,S extends org.apache.flink.api.common.state.State,IS extends S> IS createInternalState(@Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, @Nonnull org.apache.flink.api.common.state.StateDescriptor<S,SV> stateDesc, @Nonnull StateSnapshotTransformer.StateSnapshotTransformFactory<SEV> snapshotTransformFactory) throws Exception
KeyedStateFactoryInternalKvState.N - The type of the namespace.SV - The type of the stored state value.SEV - The type of the stored state value or entry for collection types (list or map).S - The type of the public API state.IS - The type of internal state.namespaceSerializer - TypeSerializer for the state namespace.stateDesc - The StateDescriptor that contains the name of the state.snapshotTransformFactory - factory of state snapshot transformer.Exception@Nonnull public RunnableFuture<SnapshotResult<KeyedStateHandle>> snapshot(long checkpointId, long timestamp, @Nonnull CheckpointStreamFactory streamFactory, @Nonnull CheckpointOptions checkpointOptions) throws Exception
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.Exception@Nonnull public SavepointResources<K> savepoint()
CheckpointableKeyedStateBackendSavepointResources that can be used by SavepointSnapshotStrategy to
write out a savepoint in the common/unified format.public void notifyCheckpointComplete(long checkpointId)
public void notifyCheckpointAborted(long checkpointId)
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,
AbstractKeyedStateBackend.PartitionStateFactory partitionStateFactory)
throws Exception
applyToAllKeys in class AbstractKeyedStateBackend<K>Exception@VisibleForTesting public int numKeyValueStateEntries()
@VisibleForTesting public int numKeyValueStateEntries(Object namespace)
@VisibleForTesting public LocalRecoveryConfig getLocalRecoveryConfig()
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.