Package hu.akarnokd.rxjava3.operators
Interface PartialCollectEmitter<T,I,A,R>
-
- Type Parameters:
T- the upstream value typeI- the type that indicates where the first cached item should be read fromA- the accumulator type used to collect up partial dataR- the output type
public interface PartialCollectEmitter<T,I,A,R>Provides callbacks and methods to support the partial collect operator: access to cached elements, save and retrieve an input index and accumulator and produce the output instance.- Since:
- 0.18.9
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcleanupItem(T item)Call the cleanup handler of the operator for a specific upstream instance.voidcomplete()Indicate that no further output items will be produced.longdemand()Returns the number of items that can be emitted vianext(Object)without overflowing the downstream.voiddropItems(int count)Remove the firstcountitems from the cache, sending them to the cleanup handler of the operator as well as possibly triggering more requests to the upstream to replenish the buffer.AgetAccumulator()Returns an optional, user-defined accumulator that can be used to aggregate partial items from upstream until enough data has been gathered.IgetIndex()Reads an optional, user-defined index that can be used to store a read pointer into the very first upstream item accessible viagetItem(int)to indicate from where to resume.TgetItem(int index)Access a cached item based on an index less thansize().booleanisCancelled()The downstream requested cancellation.booleanisComplete()The upstream completed sending new items.voidnext(R item)Signal the next output item.voidsetAccumulator(A newAccumulator)Sets an optional, user-defined accumulator that can be used to aggregate partial items from upstream.voidsetIndex(I newIndex)Sets an optional, user-defined index that can be used as a read poitner into the very first upstream item.intsize()The number of items cached and accessible viagetItem(int).
-
-
-
Method Detail
-
isCancelled
boolean isCancelled()
The downstream requested cancellation.- Returns:
- true if the downstream cancelled
-
isComplete
boolean isComplete()
The upstream completed sending new items.- Returns:
- true if the upstream completed
-
size
int size()
The number of items cached and accessible viagetItem(int).- Returns:
- the number of items cached
-
getItem
T getItem(int index)
Access a cached item based on an index less thansize().- Parameters:
index- the index- Returns:
- the item
-
dropItems
void dropItems(int count)
Remove the firstcountitems from the cache, sending them to the cleanup handler of the operator as well as possibly triggering more requests to the upstream to replenish the buffer.- Parameters:
count- the number of items to drop
-
getIndex
I getIndex()
Reads an optional, user-defined index that can be used to store a read pointer into the very first upstream item accessible viagetItem(int)to indicate from where to resume.- Returns:
- the index object
-
setIndex
void setIndex(I newIndex)
Sets an optional, user-defined index that can be used as a read poitner into the very first upstream item.- Parameters:
newIndex- the index object to set
-
getAccumulator
A getAccumulator()
Returns an optional, user-defined accumulator that can be used to aggregate partial items from upstream until enough data has been gathered.- Returns:
- the accumulator object
-
setAccumulator
void setAccumulator(A newAccumulator)
Sets an optional, user-defined accumulator that can be used to aggregate partial items from upstream.- Parameters:
newAccumulator- the new accumulator object
-
next
void next(R item)
Signal the next output item.This can be called as many times as
demand().- Parameters:
item- the item to signal
-
complete
void complete()
Indicate that no further output items will be produced.
-
cleanupItem
void cleanupItem(T item)
Call the cleanup handler of the operator for a specific upstream instance.- Parameters:
item- the item to clean up
-
demand
long demand()
Returns the number of items that can be emitted vianext(Object)without overflowing the downstream.- Returns:
- the outstanding downstream demand
-
-