T
- The type of elements in the bag.@Experimental(value=STATE) public interface BagState<T> extends GroupingState<T,java.lang.Iterable<T>>
ReadableState
cell containing a bag of values. Items can be added to the bag and the
contents read out.
Implementations of this form of state are expected to implement GroupingState.add(InputT)
efficiently, not
via a sequence of read-modify-write.
Modifier and Type | Method and Description |
---|---|
java.lang.Iterable<T> |
read()
Read the current value, blocking until it is available.
|
BagState<T> |
readLater()
Indicate that the value will be read later.
|
add, isEmpty
@Nonnull java.lang.Iterable<T> read()
ReadableState
If there will be many calls to ReadableState.read()
for different state in short succession, you
should first call ReadableState.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.
read
in interface ReadableState<java.lang.Iterable<T>>
BagState<T> readLater()
ReadableState
This allows an implementation to start an asynchronous prefetch or to include this state in the next batch of reads.
readLater
in interface GroupingState<T,java.lang.Iterable<T>>
readLater
in interface ReadableState<java.lang.Iterable<T>>