Module org.elasticsearch.xcore
Class EncodedTDigest
java.lang.Object
org.elasticsearch.xpack.core.analytics.mapper.EncodedTDigest
- All Implemented Interfaces:
org.elasticsearch.tdigest.TDigestReadView
public final class EncodedTDigest
extends Object
implements org.elasticsearch.tdigest.TDigestReadView
Read-only digest backed by encoded centroid bytes.
The encoded format is a sequence of pairs:
- centroid count as VLong
- centroid mean as IEEE754 double (8 bytes, big-endian)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceIterator over centroids in increasing mean order. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe size of a single EncodedTDigest instance in bytes, excluding the underlying encoded digest bytes array. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns an allocation-free iterator over encoded centroids.Collection<org.elasticsearch.tdigest.Centroid> static org.apache.lucene.util.BytesRefencodeCentroids(Collection<? extends org.elasticsearch.tdigest.Centroid> centroids) Encodes the provided centroids into aBytesRef.static voidencodeCentroids(Collection<? extends org.elasticsearch.tdigest.Centroid> centroids, StreamOutput out) static org.apache.lucene.util.BytesRefencodeCentroids(List<Double> means, List<Long> counts) Encodes centroids represented by independent means and counts lists.static longencodeCentroidsFromIterator(EncodedTDigest.CentroidIterator centroids, StreamOutput out) Encodes the given centroids into the given output.org.apache.lucene.util.BytesRefReturns the currently configured encoded digest bytes.doublegetMax()doublegetMin()voidreset(org.apache.lucene.util.BytesRef encodedDigest) Replaces the underlying encoded digest bytes.longsize()
-
Field Details
-
RAM_BYTES
public static final long RAM_BYTESThe size of a single EncodedTDigest instance in bytes, excluding the underlying encoded digest bytes array.
-
-
Constructor Details
-
EncodedTDigest
public EncodedTDigest() -
EncodedTDigest
public EncodedTDigest(org.apache.lucene.util.BytesRef encodedDigest)
-
-
Method Details
-
reset
public void reset(org.apache.lucene.util.BytesRef encodedDigest) Replaces the underlying encoded digest bytes. All decoding happens lazily when methods likesize()are called. The providedencodedDigestis copied shallowly, so the caller is responsible for ensuring that the bytes remain unchanged for the lifetime of this instance.- Parameters:
encodedDigest- The new encoded digest bytes. Must not be null, but may be empty.
-
encodedDigest
public org.apache.lucene.util.BytesRef encodedDigest()Returns the currently configured encoded digest bytes. -
centroidIterator
Returns an allocation-free iterator over encoded centroids. -
encodeCentroids
public static org.apache.lucene.util.BytesRef encodeCentroids(Collection<? extends org.elasticsearch.tdigest.Centroid> centroids) Encodes the provided centroids into aBytesRef. -
encodeCentroids
public static void encodeCentroids(Collection<? extends org.elasticsearch.tdigest.Centroid> centroids, StreamOutput out) throws IOException - Throws:
IOException
-
encodeCentroids
public static org.apache.lucene.util.BytesRef encodeCentroids(List<Double> means, List<Long> counts) Encodes centroids represented by independent means and counts lists. -
size
public long size()- Specified by:
sizein interfaceorg.elasticsearch.tdigest.TDigestReadView
-
centroidCount
public int centroidCount()- Specified by:
centroidCountin interfaceorg.elasticsearch.tdigest.TDigestReadView
-
getMin
public double getMin()- Specified by:
getMinin interfaceorg.elasticsearch.tdigest.TDigestReadView
-
getMax
public double getMax()- Specified by:
getMaxin interfaceorg.elasticsearch.tdigest.TDigestReadView
-
centroids
- Specified by:
centroidsin interfaceorg.elasticsearch.tdigest.TDigestReadView
-
encodeCentroidsFromIterator
public static long encodeCentroidsFromIterator(EncodedTDigest.CentroidIterator centroids, StreamOutput out) throws IOException Encodes the given centroids into the given output. Also compute the sum of all counts and returns it.- Parameters:
centroids- the centroids to encodeout- the output to encode into- Returns:
- the sum of all counts in the centroids
- Throws:
IOException
-