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)
  • Field Details

    • RAM_BYTES

      public static final long RAM_BYTES
      The 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 like size() are called. The provided encodedDigest is 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

      public EncodedTDigest.CentroidIterator 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 a BytesRef.
    • 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:
      size in interface org.elasticsearch.tdigest.TDigestReadView
    • centroidCount

      public int centroidCount()
      Specified by:
      centroidCount in interface org.elasticsearch.tdigest.TDigestReadView
    • getMin

      public double getMin()
      Specified by:
      getMin in interface org.elasticsearch.tdigest.TDigestReadView
    • getMax

      public double getMax()
      Specified by:
      getMax in interface org.elasticsearch.tdigest.TDigestReadView
    • centroids

      public Collection<org.elasticsearch.tdigest.Centroid> centroids()
      Specified by:
      centroids in interface org.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 encode
      out - the output to encode into
      Returns:
      the sum of all counts in the centroids
      Throws:
      IOException