Module org.elasticsearch.server
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.-
Field Summary
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(ExponentialHistogram histogram) doublecdf(double x) Returns the fraction of all points added which are ≤ x.intvoidclose()static ExponentialHistogramStatecreate(CircuitBreaker circuitBreaker) Creates a new, empty state.booleandoublegetMax()The maximum value of the histogram, orDouble.NEGATIVE_INFINITYif the histogram is empty.doublegetMin()The minimum value of the histogram, orDouble.POSITIVE_INFINITYif the histogram is empty.inthashCode()booleanisEmpty()doublequantile(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.longstatic ExponentialHistogramStateread(CircuitBreaker breaker, StreamInput in) longsize()Returns the number of scalar values added to this histogram, so the sum ofExponentialHistogram.valueCount()for all histograms added.voidwrite(StreamOutput out) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Method Details
-
create
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
-
size
public long size()Returns the number of scalar values added to this histogram, so the sum ofExponentialHistogram.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
- 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, orDouble.POSITIVE_INFINITYif the histogram is empty.- Returns:
- the minimum
-
getMax
public double getMax()The maximum value of the histogram, orDouble.NEGATIVE_INFINITYif the histogram is empty.- Returns:
- the maximum
-
write
- Throws:
IOException
-
read
public static ExponentialHistogramState read(CircuitBreaker breaker, StreamInput in) throws IOException - Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceReleasable
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-