Package com.google.api.gax.batching
Class NumericThreshold<E>
- java.lang.Object
-
- com.google.api.gax.batching.NumericThreshold<E>
-
- All Implemented Interfaces:
BatchingThreshold<E>
public final class NumericThreshold<E> extends java.lang.Object implements BatchingThreshold<E>
A threshold which accumulates a count based on the provided ElementCounter.
-
-
Constructor Summary
Constructors Constructor Description NumericThreshold(long threshold, ElementCounter<E> extractor)Constructs a NumericThreshold.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccumulate(E e)Presents the element to the threshold for the attribute of interest to be accumulated.BatchingThreshold<E>copyWithZeroedValue()Make a copy of this threshold but with the accumulated value zeroed.booleanisThresholdReached()Any calls into this function from ThresholdBatcher will be under a lock.
-
-
-
Constructor Detail
-
NumericThreshold
public NumericThreshold(long threshold, ElementCounter<E> extractor)Constructs a NumericThreshold.- Parameters:
threshold- The value that allows an event to happen.extractor- Object that extracts a numeric value from the value object.
-
-
Method Detail
-
accumulate
public void accumulate(E e)
Description copied from interface:BatchingThresholdPresents the element to the threshold for the attribute of interest to be accumulated.Any calls into this function from ThresholdBatcher will be under a lock.
- Specified by:
accumulatein interfaceBatchingThreshold<E>
-
isThresholdReached
public boolean isThresholdReached()
Description copied from interface:BatchingThresholdAny calls into this function from ThresholdBatcher will be under a lock.- Specified by:
isThresholdReachedin interfaceBatchingThreshold<E>- Returns:
- whether the threshold has been reached.
-
copyWithZeroedValue
public BatchingThreshold<E> copyWithZeroedValue()
Description copied from interface:BatchingThresholdMake a copy of this threshold but with the accumulated value zeroed.Any calls into this function from ThresholdBatcher will be under a lock.
- Specified by:
copyWithZeroedValuein interfaceBatchingThreshold<E>
-
-