Class ExponentialHistogramGenerator

java.lang.Object
org.elasticsearch.exponentialhistogram.ExponentialHistogramGenerator
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.lucene.util.Accountable, Releasable

public class ExponentialHistogramGenerator extends Object implements org.apache.lucene.util.Accountable, Releasable
Only intended for use in tests currently. A class for accumulating raw values into an ExponentialHistogram with a given maximum number of buckets. If the number of values is less than or equal to the bucket capacity, the resulting histogram is guaranteed to represent the exact raw values with a relative error less than 2^(2^-MAX_SCALE) - 1.
  • Method Details

    • create

      public static ExponentialHistogramGenerator create(int maxBucketCount, ExponentialHistogramCircuitBreaker circuitBreaker)
      Creates a new instance with the specified maximum number of buckets.
      Parameters:
      maxBucketCount - the maximum number of buckets for the generated histogram
      circuitBreaker - the circuit breaker to use to limit memory allocations
    • add

      public void add(double value)
      Adds the given value to the histogram.
      Parameters:
      value - the value to add
    • getAndClear

      public ReleasableExponentialHistogram getAndClear()
      Returns the histogram representing the distribution of all accumulated values.
      Returns:
      the histogram representing the distribution of all accumulated values
    • ramBytesUsed

      public long ramBytesUsed()
      Specified by:
      ramBytesUsed in interface org.apache.lucene.util.Accountable
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Releasable