Class AbstractValueState<K,N,V>
- java.lang.Object
-
- org.apache.flink.runtime.state.v2.AbstractKeyedState<K,N,V>
-
- org.apache.flink.runtime.state.v2.AbstractValueState<K,N,V>
-
- Type Parameters:
K
- The type of key the state is associated to.V
- The type of values kept internally in state.
- All Implemented Interfaces:
State
,ValueState<V>
,InternalKeyedState<K,N,V>
,InternalPartitionedState<N>
,InternalValueState<K,N,V>
- Direct Known Subclasses:
ForStValueState
public class AbstractValueState<K,N,V> extends AbstractKeyedState<K,N,V> implements InternalValueState<K,N,V>
A default implementation ofValueState
which delegates all async requests toAsyncExecutionController
.
-
-
Field Summary
-
Fields inherited from class org.apache.flink.runtime.state.v2.AbstractKeyedState
stateRequestHandler
-
-
Constructor Summary
Constructors Constructor Description AbstractValueState(StateRequestHandler stateRequestHandler, ValueStateDescriptor<V> valueStateDescriptor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StateFuture<Void>
asyncUpdate(V value)
Updates the operator state accessible byValueState.asyncValue()
to the given value asynchronously.StateFuture<V>
asyncValue()
Returns the current value for the state asynchronously.void
update(V value)
Updates the operator state accessible byValueState.value()
to the given value.V
value()
Returns the current value for the state.-
Methods inherited from class org.apache.flink.runtime.state.v2.AbstractKeyedState
asyncClear, clear, getStateDescriptor, getStateRequestHandler, getValueSerializer, handleRequest, handleRequestSync, setCurrentNamespace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.runtime.state.v2.internal.InternalPartitionedState
setCurrentNamespace
-
Methods inherited from interface org.apache.flink.api.common.state.v2.State
asyncClear, clear
-
-
-
-
Constructor Detail
-
AbstractValueState
public AbstractValueState(StateRequestHandler stateRequestHandler, ValueStateDescriptor<V> valueStateDescriptor)
-
-
Method Detail
-
asyncValue
public final StateFuture<V> asyncValue()
Description copied from interface:ValueState
Returns the current value for the state asynchronously. When the state is not partitioned the returned value is the same for all inputs in a given operator instance. If state partitioning is applied, the value returned depends on the current operator input, as the operator maintains an independent state for each partition. When no value was previously set usingValueState.asyncUpdate(Object)
, the future will returnnull
asynchronously.- Specified by:
asyncValue
in interfaceValueState<K>
- Returns:
- The
StateFuture
that will return the value corresponding to the current input.
-
asyncUpdate
public final StateFuture<Void> asyncUpdate(V value)
Description copied from interface:ValueState
Updates the operator state accessible byValueState.asyncValue()
to the given value asynchronously. The next timeValueState.asyncValue()
is called (for the same state partition) the returned state will represent the updated value. When a partitioned state is updated withnull
, the state for the current key will be removed.- Specified by:
asyncUpdate
in interfaceValueState<K>
- Parameters:
value
- The new value for the state.- Returns:
- The
StateFuture
that will trigger the callback when update finishes.
-
value
public V value()
Description copied from interface:ValueState
Returns the current value for the state. When the state is not partitioned the returned value is the same for all inputs in a given operator instance. If state partitioning is applied, the value returned depends on the current operator input, as the operator maintains an independent state for each partition.If you didn't specify a default value when creating the ValueStateDescriptor this will return
null
when no value was previously set usingValueState.update(Object)
.- Specified by:
value
in interfaceValueState<K>
- Returns:
- The state value corresponding to the current input.
-
update
public void update(V value)
Description copied from interface:ValueState
Updates the operator state accessible byValueState.value()
to the given value. The next timeValueState.value()
is called (for the same state partition) the returned state will represent the updated value. When a partitioned state is updated withnull
, the state for the current key will be removed and the default value is returned on the next access.- Specified by:
update
in interfaceValueState<K>
- Parameters:
value
- The new value for the state.
-
-