Class ThresholdBatcher<E> (2.13.0)

public final class ThresholdBatcher<E>

Queues up elements until either a duration of time has passed or any threshold in a given set of thresholds is breached, and then delivers the elements in a batch to the consumer.

Inheritance

java.lang.Object > ThresholdBatcher<E>

Type Parameter

NameDescription
E

Static Methods

<E>newBuilder()

public static ThresholdBatcher.Builder<E> <E>newBuilder()

Get a new builder for a ThresholdBatcher.

Returns
TypeDescription
Builder<E>

Methods

add(E e)

public void add(E e)

Adds an element to the batcher. If the element causes the collection to go past any of the thresholds, the batch will be sent to the ThresholdBatchReceiver.

Parameter
NameDescription
eE
Exceptions
TypeDescription
FlowController.FlowControlException

pushCurrentBatch()

public ApiFuture<Void> pushCurrentBatch()

Push the current batch to the batch receiver. Returns an ApiFuture that completes once the batch has been processed by the batch receiver and the flow controller resources have been released.

Note that this future can complete for the current batch before previous batches have completed, so it cannot be depended upon for flushing.

Returns
TypeDescription
com.google.api.core.ApiFuture<Void>