Class DefaultStateManager
- java.lang.Object
-
- org.apache.flink.datastream.impl.context.DefaultStateManager
-
- All Implemented Interfaces:
StateManager
public class DefaultStateManager extends Object implements StateManager
The default implementation ofStateManager
. This class supports eagerly set and reset the current key.
-
-
Field Summary
Fields Modifier and Type Field Description protected StreamingRuntimeContext
operatorContext
protected OperatorStateStore
operatorStateStore
-
Constructor Summary
Constructors Constructor Description DefaultStateManager(Supplier<Object> currentKeySupplier, Consumer<Object> currentKeySetter, StreamingRuntimeContext operatorContext, OperatorStateStore operatorStateStore)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
executeInKeyContext(Runnable runnable, Object key)
This method should be used to run a block of code with a specific key context.<K> K
getCurrentKey()
Get the key of current record.<IN,ACC,OUT>
Optional<AggregatingState<IN,OUT>>getState(AggregatingStateDeclaration<IN,ACC,OUT> stateDeclaration)
Get the specific aggregating state.<K,V>
Optional<BroadcastState<K,V>>getState(BroadcastStateDeclaration<K,V> stateDeclaration)
Get the specific broadcast state.<T> Optional<ListState<T>>
getState(ListStateDeclaration<T> stateDeclaration)
Get the specific list state.<K,V>
Optional<MapState<K,V>>getState(MapStateDeclaration<K,V> stateDeclaration)
Get the specific map state.<T> Optional<ReducingState<T>>
getState(ReducingStateDeclaration<T> stateDeclaration)
Get the specific reducing state.<T> Optional<ValueState<T>>
getState(ValueStateDeclaration<T> stateDeclaration)
Get the specific value state.
-
-
-
Field Detail
-
operatorContext
protected final StreamingRuntimeContext operatorContext
-
operatorStateStore
protected final OperatorStateStore operatorStateStore
-
-
Constructor Detail
-
DefaultStateManager
public DefaultStateManager(Supplier<Object> currentKeySupplier, Consumer<Object> currentKeySetter, StreamingRuntimeContext operatorContext, OperatorStateStore operatorStateStore)
-
-
Method Detail
-
getCurrentKey
public <K> K getCurrentKey()
Description copied from interface:StateManager
Get the key of current record.- Specified by:
getCurrentKey
in interfaceStateManager
- Returns:
- The key of current processed record.
-
getState
public <T> Optional<ValueState<T>> getState(ValueStateDeclaration<T> stateDeclaration) throws Exception
Description copied from interface:StateManager
Get the specific value state.- Specified by:
getState
in interfaceStateManager
- Parameters:
stateDeclaration
- of this state.- Returns:
- the value state corresponds to the state declaration.
- Throws:
Exception
-
getState
public <T> Optional<ListState<T>> getState(ListStateDeclaration<T> stateDeclaration) throws Exception
Description copied from interface:StateManager
Get the specific list state.- Specified by:
getState
in interfaceStateManager
- Parameters:
stateDeclaration
- of this state.- Returns:
- the list state corresponds to the state declaration.
- Throws:
Exception
-
getState
public <K,V> Optional<MapState<K,V>> getState(MapStateDeclaration<K,V> stateDeclaration) throws Exception
Description copied from interface:StateManager
Get the specific map state.- Specified by:
getState
in interfaceStateManager
- Parameters:
stateDeclaration
- of this state.- Returns:
- the map state corresponds to the state declaration.
- Throws:
Exception
-
getState
public <T> Optional<ReducingState<T>> getState(ReducingStateDeclaration<T> stateDeclaration) throws Exception
Description copied from interface:StateManager
Get the specific reducing state.- Specified by:
getState
in interfaceStateManager
- Parameters:
stateDeclaration
- of this state.- Returns:
- the reducing state corresponds to the state declaration.
- Throws:
Exception
-
getState
public <IN,ACC,OUT> Optional<AggregatingState<IN,OUT>> getState(AggregatingStateDeclaration<IN,ACC,OUT> stateDeclaration) throws Exception
Description copied from interface:StateManager
Get the specific aggregating state.- Specified by:
getState
in interfaceStateManager
- Parameters:
stateDeclaration
- of this state.- Returns:
- the aggregating state corresponds to the state declaration.
- Throws:
Exception
-
getState
public <K,V> Optional<BroadcastState<K,V>> getState(BroadcastStateDeclaration<K,V> stateDeclaration) throws Exception
Description copied from interface:StateManager
Get the specific broadcast state.- Specified by:
getState
in interfaceStateManager
- Parameters:
stateDeclaration
- of this state.- Returns:
- the broadcast state corresponds to the state declaration.
- Throws:
Exception
-
-