Class ExponentialHistogramState

java.lang.Object
org.elasticsearch.search.aggregations.metrics.ExponentialHistogramState
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.lucene.util.Accountable, Releasable

public class ExponentialHistogramState extends Object implements Releasable, org.apache.lucene.util.Accountable
Decorates ExponentialHistogram with custom serialization and implements commonly used functionality for aggregations.
  • Method Details

    • create

      public static ExponentialHistogramState create(CircuitBreaker circuitBreaker)
      Creates a new, empty state.
      Parameters:
      circuitBreaker - the circuit breaker to use for tracking memory usage
      Returns:
      a new, empty state
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if this state does not contain any histogram data, e.g. it was just created without adding any histograms.
    • add

      public void add(ExponentialHistogram histogram)
    • size

      public long size()
      Returns the number of scalar values added to this histogram, so the sum of ExponentialHistogram.valueCount() for all histograms added.
      Returns:
      the number of values
    • cdf

      public double cdf(double x)
      Returns the fraction of all points added which are ≤ x. Points that are exactly equal get half credit (i.e. we use the mid-point rule)
      Parameters:
      x - The cutoff for the cdf.
      Returns:
      The fraction of all data which is less or equal to x.
    • quantile

      public double quantile(double q)
      Returns an estimate of a cutoff such that a specified fraction of the data added to this histogram would be less than or equal to the cutoff.
      Parameters:
      q - The desired fraction
      Returns:
      The smallest value x such that cdf(x) ≥ q
    • centroids

      public Collection<Centroid> centroids()
      Returns:
      an array of the mean values of the populated histogram buckets with their counts
    • centroidCount

      public int centroidCount()
      Returns:
      the length of the array returned by centroids().
    • getMin

      public double getMin()
      The minimum value of the histogram, or Double.POSITIVE_INFINITY if the histogram is empty.
      Returns:
      the minimum
    • getMax

      public double getMax()
      The maximum value of the histogram, or Double.NEGATIVE_INFINITY if the histogram is empty.
      Returns:
      the maximum
    • write

      public void write(StreamOutput out) throws IOException
      Throws:
      IOException
    • read

      public static ExponentialHistogramState read(CircuitBreaker breaker, StreamInput in) throws IOException
      Throws:
      IOException
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • close

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

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