Class AbstractAggregatingState<K,N,IN,ACC,OUT>
- java.lang.Object
-
- org.apache.flink.runtime.state.v2.AbstractKeyedState<K,N,ACC>
-
- org.apache.flink.runtime.state.v2.AbstractAggregatingState<K,N,IN,ACC,OUT>
-
- Type Parameters:
K
- The type of key the state is associated to.IN
- The type of the values that are added into the state.ACC
- TThe type of the accumulator (intermediate aggregation state).OUT
- The type of the values that are returned from the state.
- All Implemented Interfaces:
AggregatingState<IN,OUT>
,AppendingState<IN,OUT,OUT>
,MergingState<IN,OUT,OUT>
,State
,InternalAggregatingState<K,N,IN,ACC,OUT>
,InternalAppendingState<K,N,IN,ACC,OUT,OUT>
,InternalKeyedState<K,N,ACC>
,InternalMergingState<K,N,IN,ACC,OUT,OUT>
,InternalPartitionedState<N>
- Direct Known Subclasses:
ForStAggregatingState
public class AbstractAggregatingState<K,N,IN,ACC,OUT> extends AbstractKeyedState<K,N,ACC> implements InternalAggregatingState<K,N,IN,ACC,OUT>
The default implementation ofAggregatingState
, which delegates all async requests toStateRequestHandler
.
-
-
Field Summary
Fields Modifier and Type Field Description protected AggregateFunction<IN,ACC,OUT>
aggregateFunction
-
Fields inherited from class org.apache.flink.runtime.state.v2.AbstractKeyedState
stateRequestHandler
-
-
Constructor Summary
Constructors Constructor Description AbstractAggregatingState(StateRequestHandler stateRequestHandler, AggregatingStateDescriptor<IN,ACC,OUT> stateDescriptor)
Creates a new AbstractKeyedState with the given asyncExecutionController and stateDescriptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(IN value)
Updates the operator state accessible byAppendingState.get()
by adding the given value to the list of values.StateFuture<Void>
asyncAdd(IN value)
Updates the operator state accessible byAppendingState.asyncGet()
by adding the given value to the list of values asynchronously.StateFuture<OUT>
asyncGet()
Returns the current value for the state asynchronously.StateFuture<ACC>
asyncGetInternal()
Get internally stored value.StateFuture<Void>
asyncMergeNamespaces(N target, Collection<N> sources)
Merges the state of the current key for the given source namespaces into the state of the target namespace.StateFuture<Void>
asyncUpdateInternal(ACC valueToStore)
Update internally stored value.OUT
get()
Returns the current value for the state.ACC
getInternal()
Get internally stored value.void
mergeNamespaces(N target, Collection<N> sources)
Merges the state of the current key for the given source namespaces into the state of the target namespace.void
updateInternal(ACC valueToStore)
Update internally stored value.-
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
-
-
-
-
Field Detail
-
aggregateFunction
protected final AggregateFunction<IN,ACC,OUT> aggregateFunction
-
-
Constructor Detail
-
AbstractAggregatingState
public AbstractAggregatingState(StateRequestHandler stateRequestHandler, AggregatingStateDescriptor<IN,ACC,OUT> stateDescriptor)
Creates a new AbstractKeyedState with the given asyncExecutionController and stateDescriptor.- Parameters:
stateRequestHandler
- The async request handler for handling all requests.stateDescriptor
- The properties of the state.
-
-
Method Detail
-
asyncGet
public StateFuture<OUT> asyncGet()
Description copied from interface:AppendingState
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.NOTE TO IMPLEMENTERS: if the state is empty, then this method should return
null
wrapped by a StateFuture.- Specified by:
asyncGet
in interfaceAppendingState<K,N,IN>
- Returns:
- The operator state value corresponding to the current input or
null
wrapped by aStateFuture
if the state is empty.
-
asyncAdd
public StateFuture<Void> asyncAdd(IN value)
Description copied from interface:AppendingState
Updates the operator state accessible byAppendingState.asyncGet()
by adding the given value to the list of values asynchronously. The next timeAppendingState.asyncGet()
is called (for the same state partition) the returned state will represent the updated list.null value is not allowed to be passed in.
- Specified by:
asyncAdd
in interfaceAppendingState<K,N,IN>
- Parameters:
value
- The new value for the state.
-
asyncGetInternal
public StateFuture<ACC> asyncGetInternal()
Description copied from interface:InternalAppendingState
Get internally stored value.- Specified by:
asyncGetInternal
in interfaceInternalAppendingState<K,N,IN,ACC,OUT,OUT>
- Returns:
- internally stored value.
-
asyncUpdateInternal
public StateFuture<Void> asyncUpdateInternal(ACC valueToStore)
Description copied from interface:InternalAppendingState
Update internally stored value.- Specified by:
asyncUpdateInternal
in interfaceInternalAppendingState<K,N,IN,ACC,OUT,OUT>
- Parameters:
valueToStore
- new value to store.
-
get
public OUT get()
Description copied from interface:AppendingState
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.NOTE TO IMPLEMENTERS: if the state is empty, then this method should return
null
.- Specified by:
get
in interfaceAppendingState<K,N,IN>
- Returns:
- The operator state value corresponding to the current input or
null
if the state is empty.
-
add
public void add(IN value)
Description copied from interface:AppendingState
Updates the operator state accessible byAppendingState.get()
by adding the given value to the list of values. The next timeAppendingState.get()
is called (for the same state partition) the returned state will represent the updated list.If null is passed in, the behaviour is undefined (implementation related).
- Specified by:
add
in interfaceAppendingState<K,N,IN>
- Parameters:
value
- The new value for the state.
-
asyncMergeNamespaces
public StateFuture<Void> asyncMergeNamespaces(N target, Collection<N> sources)
Description copied from interface:InternalMergingState
Merges the state of the current key for the given source namespaces into the state of the target namespace.- Specified by:
asyncMergeNamespaces
in interfaceInternalMergingState<K,N,IN,ACC,OUT,OUT>
- Parameters:
target
- The target namespace where the merged state should be stored.sources
- The source namespaces whose state should be merged.
-
mergeNamespaces
public void mergeNamespaces(N target, Collection<N> sources)
Description copied from interface:InternalMergingState
Merges the state of the current key for the given source namespaces into the state of the target namespace.- Specified by:
mergeNamespaces
in interfaceInternalMergingState<K,N,IN,ACC,OUT,OUT>
- Parameters:
target
- The target namespace where the merged state should be stored.sources
- The source namespaces whose state should be merged.
-
getInternal
public ACC getInternal()
Description copied from interface:InternalAppendingState
Get internally stored value.- Specified by:
getInternal
in interfaceInternalAppendingState<K,N,IN,ACC,OUT,OUT>
- Returns:
- internally stored value.
-
updateInternal
public void updateInternal(ACC valueToStore)
Description copied from interface:InternalAppendingState
Update internally stored value.- Specified by:
updateInternal
in interfaceInternalAppendingState<K,N,IN,ACC,OUT,OUT>
- Parameters:
valueToStore
- new value to store.
-
-