K
- The key by which state is keyed.public interface KeyedStateBackend<K> extends KeyedStateFactory, PriorityQueueSetFactory, org.apache.flink.util.Disposable
限定符和类型 | 接口和说明 |
---|---|
static interface |
KeyedStateBackend.KeySelectionListener<K>
Listener is given a callback when
setCurrentKey(K) is called (key context changes). |
限定符和类型 | 方法和说明 |
---|---|
<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. |
boolean |
deregisterKeySelectionListener(KeyedStateBackend.KeySelectionListener<K> listener)
Stop calling listener registered in
registerKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K>) . |
void |
dispose() |
K |
getCurrentKey() |
<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) |
org.apache.flink.api.common.typeutils.TypeSerializer<K> |
getKeySerializer() |
<N,S extends org.apache.flink.api.common.state.State,T> |
getOrCreateKeyedState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,T> stateDescriptor)
Creates or retrieves a keyed state backed by this state backend.
|
<N,S extends org.apache.flink.api.common.state.State> |
getPartitionedState(N namespace,
org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,?> stateDescriptor)
Creates or retrieves a partitioned state backed by this state backend.
|
void |
registerKeySelectionListener(KeyedStateBackend.KeySelectionListener<K> listener)
State backend will call
KeyedStateBackend.KeySelectionListener.keySelected(K) when key context is switched
if supported. |
void |
setCurrentKey(K newKey)
Sets the current key that is used for partitioned state.
|
createInternalState, createInternalState
create
void setCurrentKey(K newKey)
newKey
- The new current key.K getCurrentKey()
org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()
<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
KeyedStateFunction
to the state with the provided StateDescriptor
of all the currently active keys.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.Exception
<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.<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.<N,S extends org.apache.flink.api.common.state.State,T> S getOrCreateKeyedState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.StateDescriptor<S,T> stateDescriptor) throws Exception
N
- The type of the namespace.S
- The type of the state.namespaceSerializer
- The serializer used for the namespace type of the statestateDescriptor
- The identifier for the state. This contains name and can create a
default state value.Exception
- Exceptions may occur during initialization of the state and should be
forwarded.<N,S extends org.apache.flink.api.common.state.State> S getPartitionedState(N namespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.StateDescriptor<S,?> stateDescriptor) throws Exception
TODO: NOTE: This method does a lot of work caching / retrieving states just to update the namespace. This method should be removed for the sake of namespaces being lazily fetched from the keyed state backend, or being set on the state directly.
N
- The type of the namespace.S
- The type of the state.stateDescriptor
- The identifier for the state. This contains name and can create a
default state value.Exception
- Exceptions may occur during initialization of the state and should be
forwarded.void dispose()
dispose
在接口中 org.apache.flink.util.Disposable
void registerKeySelectionListener(KeyedStateBackend.KeySelectionListener<K> listener)
KeyedStateBackend.KeySelectionListener.keySelected(K)
when key context is switched
if supported.boolean deregisterKeySelectionListener(KeyedStateBackend.KeySelectionListener<K> listener)
registerKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K>)
.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.