public class DefaultStateManager extends Object implements StateManager
StateManager
. This class supports eagerly set and reset the
current key.Modifier and Type | Field and Description |
---|---|
protected StreamingRuntimeContext |
operatorContext |
protected OperatorStateStore |
operatorStateStore |
Constructor and Description |
---|
DefaultStateManager(java.util.function.Supplier<Object> currentKeySupplier,
java.util.function.Consumer<Object> currentKeySetter,
StreamingRuntimeContext operatorContext,
OperatorStateStore operatorStateStore) |
Modifier and Type | Method and 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> |
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.
|
protected final StreamingRuntimeContext operatorContext
protected final OperatorStateStore operatorStateStore
public DefaultStateManager(java.util.function.Supplier<Object> currentKeySupplier, java.util.function.Consumer<Object> currentKeySetter, StreamingRuntimeContext operatorContext, OperatorStateStore operatorStateStore)
public <K> K getCurrentKey()
StateManager
getCurrentKey
in interface StateManager
public <T> Optional<ValueState<T>> getState(ValueStateDeclaration<T> stateDeclaration) throws Exception
StateManager
getState
in interface StateManager
stateDeclaration
- of this state.Exception
public <T> Optional<ListState<T>> getState(ListStateDeclaration<T> stateDeclaration) throws Exception
StateManager
getState
in interface StateManager
stateDeclaration
- of this state.Exception
public <K,V> Optional<MapState<K,V>> getState(MapStateDeclaration<K,V> stateDeclaration) throws Exception
StateManager
getState
in interface StateManager
stateDeclaration
- of this state.Exception
public <T> Optional<ReducingState<T>> getState(ReducingStateDeclaration<T> stateDeclaration) throws Exception
StateManager
getState
in interface StateManager
stateDeclaration
- of this state.Exception
public <IN,ACC,OUT> Optional<AggregatingState<IN,OUT>> getState(AggregatingStateDeclaration<IN,ACC,OUT> stateDeclaration) throws Exception
StateManager
getState
in interface StateManager
stateDeclaration
- of this state.Exception
public <K,V> Optional<BroadcastState<K,V>> getState(BroadcastStateDeclaration<K,V> stateDeclaration) throws Exception
StateManager
getState
in interface StateManager
stateDeclaration
- of this state.Exception
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.