Class NumericThreshold<E>

java.lang.Object
com.google.api.gax.batching.NumericThreshold<E>
All Implemented Interfaces:
BatchingThreshold<E>

public final class NumericThreshold<E> extends Object implements BatchingThreshold<E>
A threshold which accumulates a count based on the provided ElementCounter.
  • Constructor Details

    • 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 Details

    • accumulate

      public void accumulate(E e)
      Description copied from interface: BatchingThreshold
      Presents 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:
      accumulate in interface BatchingThreshold<E>
    • isThresholdReached

      public boolean isThresholdReached()
      Description copied from interface: BatchingThreshold
      Any calls into this function from ThresholdBatcher will be under a lock.
      Specified by:
      isThresholdReached in interface BatchingThreshold<E>
      Returns:
      whether the threshold has been reached.
    • copyWithZeroedValue

      public BatchingThreshold<E> copyWithZeroedValue()
      Description copied from interface: BatchingThreshold
      Make 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:
      copyWithZeroedValue in interface BatchingThreshold<E>