Interface CombiningState<InputT,AccumT,OutputT>
- Type Parameters:
InputT
- the type of values added to the stateAccumT
- the type of accumulatorOutputT
- the type of value extracted from the state
- All Superinterfaces:
GroupingState<InputT,
,OutputT> ReadableState<OutputT>
,State
ReadableState
cell defined by a Combine.CombineFn
, accepting multiple input values,
combining them as specified into accumulators, and producing a single output value.
Implementations of this form of state are expected to implement GroupingState.add(InputT)
efficiently, not
via a sequence of read-modify-write.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an accumulator to this state cell.getAccum()
Read the merged accumulator for this state cell.mergeAccumulators
(Iterable<AccumT> accumulators) Merge the given accumulators according to the underlyingCombine.CombineFn
.read()
Read the current value, blocking until it is available.Indicate that the value will be read later.Methods inherited from interface org.apache.beam.sdk.state.GroupingState
add, isEmpty
-
Method Details
-
read
Description copied from interface:ReadableState
Read the current value, blocking until it is available.If there will be many calls to
ReadableState.read()
for different state in short succession, you should first callReadableState.readLater()
for all of them so the reads can potentially be batched (depending on the underlying implementation}.The returned object should be independent of the underlying state. Any direct modification of the returned object should not modify state without going through the appropriate state interface, and modification to the state should not be mirrored in the returned object.
- Specified by:
read
in interfaceReadableState<InputT>
-
getAccum
AccumT getAccum()Read the merged accumulator for this state cell. It is implied that reading the state involves reading the accumulator, soreadLater()
is sufficient to prefetch for this. -
addAccum
Add an accumulator to this state cell. Depending on implementation this may immediately merge it with the previous accumulator, or may buffer this accumulator for a future merge. -
mergeAccumulators
Merge the given accumulators according to the underlyingCombine.CombineFn
. -
readLater
CombiningState<InputT,AccumT, readLater()OutputT> Description copied from interface:ReadableState
Indicate that the value will be read later.This allows an implementation to start an asynchronous prefetch or to include this state in the next batch of reads.
- Specified by:
readLater
in interfaceGroupingState<InputT,
AccumT> - Specified by:
readLater
in interfaceReadableState<InputT>
- Returns:
- this for convenient chaining
-