Class QuantileDigest
- java.lang.Object
-
- org.apache.pinot.segment.local.customobject.QuantileDigest
-
public class QuantileDigest extends Object
Re-implement io.airlift.stats.QuantileDigest with additional methods facilitating serialization.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classQuantileDigest.Bucket
-
Constructor Summary
Constructors Constructor Description QuantileDigest(double maxError)Create a QuantileDigest with a maximum error guarantee of "maxError" and no decay.QuantileDigest(double maxError, double alpha)Create a QuantileDigest with a maximum error guarantee of "maxError" and exponential decay with factor "alpha".QuantileDigest(QuantileDigest quantileDigest)
-
Method Summary
Modifier and Type Method Description voidadd(long value)voidadd(long value, long count)Adds a value to this digest.booleanequivalent(QuantileDigest other)static <T> TfirstNonNull(T first, T second)static QuantileDigestfromByteBuffer(ByteBuffer byteBuffer)static QuantileDigestfromBytes(byte[] bytes)doublegetAlpha()intgetByteSize()doublegetConfidenceFactor()Computes the maximum error of the current digestdoublegetCount()Number (decayed) of elements added to this quantile digestList<QuantileDigest.Bucket>getHistogram(List<Long> bucketUpperBounds)longgetMax()doublegetMaxError()longgetMin()longgetQuantile(double quantile)Gets the value at the specified quantile +/- maxError.List<Long>getQuantiles(List<Double> quantiles)Gets the values at the specified quantiles +/- maxError.static QuantileDigestmerge(List<QuantileDigest> digests)voidmerge(QuantileDigest other)voidoffer(long value)byte[]toBytes()StringtoGraphviz()
-
-
-
Constructor Detail
-
QuantileDigest
public QuantileDigest(double maxError)
Create a QuantileDigest with a maximum error guarantee of "maxError" and no decay.
- Parameters:
maxError- the max error tolerance
-
QuantileDigest
public QuantileDigest(double maxError, double alpha)Create a QuantileDigest with a maximum error guarantee of "maxError" and exponential decay with factor "alpha".
- Parameters:
maxError- the max error tolerancealpha- the exponential decay factor
-
QuantileDigest
public QuantileDigest(QuantileDigest quantileDigest)
-
-
Method Detail
-
getMaxError
public double getMaxError()
-
getAlpha
public double getAlpha()
-
add
public void add(long value)
-
add
public void add(long value, long count)Adds a value to this digest. The value must be>= 0
-
merge
public void merge(QuantileDigest other)
-
getQuantiles
public List<Long> getQuantiles(List<Double> quantiles)
Gets the values at the specified quantiles +/- maxError. The list of quantiles must be sorted in increasing order, and each value must be in the range [0, 1]
-
getQuantile
public long getQuantile(double quantile)
Gets the value at the specified quantile +/- maxError. The quantile must be in the range [0, 1]
-
getCount
public double getCount()
Number (decayed) of elements added to this quantile digest
-
getHistogram
public List<QuantileDigest.Bucket> getHistogram(List<Long> bucketUpperBounds)
-
getMin
public long getMin()
-
getMax
public long getMax()
-
getByteSize
public int getByteSize()
-
toBytes
public byte[] toBytes()
-
fromBytes
public static QuantileDigest fromBytes(byte[] bytes)
-
fromByteBuffer
public static QuantileDigest fromByteBuffer(ByteBuffer byteBuffer)
-
getConfidenceFactor
public double getConfidenceFactor()
Computes the maximum error of the current digest
-
equivalent
public boolean equivalent(QuantileDigest other)
-
toGraphviz
public String toGraphviz()
-
firstNonNull
public static <T> T firstNonNull(T first, T second)
-
offer
public void offer(long value)
-
merge
public static QuantileDigest merge(List<QuantileDigest> digests)
-
-