Class DefaultStateManager
java.lang.Object
org.apache.flink.datastream.impl.context.DefaultStateManager
- All Implemented Interfaces:
org.apache.flink.datastream.api.context.StateManager
public class DefaultStateManager
extends Object
implements org.apache.flink.datastream.api.context.StateManager
The default implementation of
StateManager. This class supports eagerly set and reset the
current key.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.flink.streaming.api.operators.StreamingRuntimeContextprotected final org.apache.flink.api.common.state.OperatorStateStore -
Constructor Summary
ConstructorsConstructorDescriptionDefaultStateManager(Supplier<Object> currentKeySupplier, BiConsumer<Runnable, Object> processorWithKey, org.apache.flink.streaming.api.operators.StreamingRuntimeContext operatorContext, org.apache.flink.api.common.state.OperatorStateStore operatorStateStore) -
Method Summary
Modifier and TypeMethodDescriptionvoidexecuteInKeyContext(Runnable runnable, Object key) This method should be used to run a block of code with a specific key context.<K> K<IN,ACC, OUT>
org.apache.flink.api.common.state.v2.AggregatingState<IN,OUT> getState(org.apache.flink.api.common.state.AggregatingStateDeclaration<IN, ACC, OUT> stateDeclaration) <K,V> org.apache.flink.api.common.state.BroadcastState<K, V> getState(org.apache.flink.api.common.state.BroadcastStateDeclaration<K, V> stateDeclaration) <T> org.apache.flink.api.common.state.v2.ListState<T>getState(org.apache.flink.api.common.state.ListStateDeclaration<T> stateDeclaration) <K,V> org.apache.flink.api.common.state.v2.MapState<K, V> getState(org.apache.flink.api.common.state.MapStateDeclaration<K, V> stateDeclaration) <T> org.apache.flink.api.common.state.v2.ReducingState<T>getState(org.apache.flink.api.common.state.ReducingStateDeclaration<T> stateDeclaration) <T> org.apache.flink.api.common.state.v2.ValueState<T>getState(org.apache.flink.api.common.state.ValueStateDeclaration<T> stateDeclaration) <IN,ACC, OUT>
Optional<org.apache.flink.api.common.state.v2.AggregatingState<IN,OUT>> getStateOptional(org.apache.flink.api.common.state.AggregatingStateDeclaration<IN, ACC, OUT> stateDeclaration) <K,V> Optional<org.apache.flink.api.common.state.BroadcastState<K, V>> getStateOptional(org.apache.flink.api.common.state.BroadcastStateDeclaration<K, V> stateDeclaration) <T> Optional<org.apache.flink.api.common.state.v2.ListState<T>>getStateOptional(org.apache.flink.api.common.state.ListStateDeclaration<T> stateDeclaration) <K,V> Optional<org.apache.flink.api.common.state.v2.MapState<K, V>> getStateOptional(org.apache.flink.api.common.state.MapStateDeclaration<K, V> stateDeclaration) <T> Optional<org.apache.flink.api.common.state.v2.ReducingState<T>>getStateOptional(org.apache.flink.api.common.state.ReducingStateDeclaration<T> stateDeclaration) <T> Optional<org.apache.flink.api.common.state.v2.ValueState<T>>getStateOptional(org.apache.flink.api.common.state.ValueStateDeclaration<T> stateDeclaration)
-
Field Details
-
operatorContext
protected final org.apache.flink.streaming.api.operators.StreamingRuntimeContext operatorContext -
operatorStateStore
protected final org.apache.flink.api.common.state.OperatorStateStore operatorStateStore
-
-
Constructor Details
-
DefaultStateManager
public DefaultStateManager(Supplier<Object> currentKeySupplier, BiConsumer<Runnable, Object> processorWithKey, org.apache.flink.streaming.api.operators.StreamingRuntimeContext operatorContext, org.apache.flink.api.common.state.OperatorStateStore operatorStateStore)
-
-
Method Details
-
getCurrentKey
public <K> K getCurrentKey()- Specified by:
getCurrentKeyin interfaceorg.apache.flink.datastream.api.context.StateManager
-
getStateOptional
public <T> Optional<org.apache.flink.api.common.state.v2.ValueState<T>> getStateOptional(org.apache.flink.api.common.state.ValueStateDeclaration<T> stateDeclaration) throws Exception - Specified by:
getStateOptionalin interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
getState
public <T> org.apache.flink.api.common.state.v2.ValueState<T> getState(org.apache.flink.api.common.state.ValueStateDeclaration<T> stateDeclaration) throws Exception - Specified by:
getStatein interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
getStateOptional
public <T> Optional<org.apache.flink.api.common.state.v2.ListState<T>> getStateOptional(org.apache.flink.api.common.state.ListStateDeclaration<T> stateDeclaration) throws Exception - Specified by:
getStateOptionalin interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
getState
public <T> org.apache.flink.api.common.state.v2.ListState<T> getState(org.apache.flink.api.common.state.ListStateDeclaration<T> stateDeclaration) throws Exception - Specified by:
getStatein interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
getStateOptional
public <K,V> Optional<org.apache.flink.api.common.state.v2.MapState<K,V>> getStateOptional(org.apache.flink.api.common.state.MapStateDeclaration<K, V> stateDeclaration) throws Exception- Specified by:
getStateOptionalin interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
getState
public <K,V> org.apache.flink.api.common.state.v2.MapState<K,V> getState(org.apache.flink.api.common.state.MapStateDeclaration<K, V> stateDeclaration) throws Exception- Specified by:
getStatein interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
getStateOptional
public <T> Optional<org.apache.flink.api.common.state.v2.ReducingState<T>> getStateOptional(org.apache.flink.api.common.state.ReducingStateDeclaration<T> stateDeclaration) throws Exception - Specified by:
getStateOptionalin interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
getState
public <T> org.apache.flink.api.common.state.v2.ReducingState<T> getState(org.apache.flink.api.common.state.ReducingStateDeclaration<T> stateDeclaration) throws Exception - Specified by:
getStatein interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
getStateOptional
public <IN,ACC, Optional<org.apache.flink.api.common.state.v2.AggregatingState<IN,OUT> OUT>> getStateOptional(org.apache.flink.api.common.state.AggregatingStateDeclaration<IN, ACC, throws ExceptionOUT> stateDeclaration) - Specified by:
getStateOptionalin interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
getState
public <IN,ACC, org.apache.flink.api.common.state.v2.AggregatingState<IN,OUT> OUT> getState(org.apache.flink.api.common.state.AggregatingStateDeclaration<IN, ACC, throws ExceptionOUT> stateDeclaration) - Specified by:
getStatein interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
getStateOptional
public <K,V> Optional<org.apache.flink.api.common.state.BroadcastState<K,V>> getStateOptional(org.apache.flink.api.common.state.BroadcastStateDeclaration<K, V> stateDeclaration) throws Exception- Specified by:
getStateOptionalin interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
getState
public <K,V> org.apache.flink.api.common.state.BroadcastState<K,V> getState(org.apache.flink.api.common.state.BroadcastStateDeclaration<K, V> stateDeclaration) throws Exception- Specified by:
getStatein interfaceorg.apache.flink.datastream.api.context.StateManager- Throws:
Exception
-
executeInKeyContext
This method should be used to run a block of code with a specific key context. The original key must be reset after the block is executed.
-