Class NumericEquiDepthHistogram

java.lang.Object
org.apache.drill.exec.planner.common.NumericEquiDepthHistogram
All Implemented Interfaces:
Histogram

public class NumericEquiDepthHistogram extends Object implements Histogram
A column specific equi-depth histogram which is meant for numeric data types
  • Constructor Details

    • NumericEquiDepthHistogram

      public NumericEquiDepthHistogram()
    • NumericEquiDepthHistogram

      public NumericEquiDepthHistogram(int numBuckets)
  • Method Details

    • getNumRowsPerBucket

      public double getNumRowsPerBucket()
    • setNumRowsPerBucket

      public void setNumRowsPerBucket(double numRows)
    • getBuckets

      public Double[] getBuckets()
    • setBucketValue

      protected void setBucketValue(int index, Double value)
    • getNumBuckets

      public int getNumBuckets()
      Get the number of buckets in the histogram number of buckets is 1 less than the total # entries in the buckets array since last entry is the end point of the last bucket
    • estimatedSelectivity

      public Double estimatedSelectivity(org.apache.calcite.rex.RexNode columnFilter, long totalRowCount, long ndv)
      Estimate the selectivity of a filter which may contain several range predicates and in the general case is of type: col op value1 AND col op value2 AND col op value3 ...

      e.g a > 10 AND a < 50 AND a >= 20 AND a <= 70 ...

      Even though in most cases it will have either 1 or 2 range conditions, we still have to handle the general case For each conjunct, we will find the histogram bucket ranges and intersect them, taking into account that the first and last bucket may be partially covered and all other buckets in the middle are fully covered.
      Specified by:
      estimatedSelectivity in interface Histogram
      Returns:
      estimated selectivity or NULL if it could not be estimated for any reason
    • getSelectedRows

      protected long getSelectedRows(org.apache.drill.shaded.guava.com.google.common.collect.Range range, long ndv)
    • buildFromTDigest

      public static NumericEquiDepthHistogram buildFromTDigest(byte[] tdigest_array, int numBuckets, long nonNullCount)
      Build a Numeric Equi-Depth Histogram from a t-digest byte array
      Parameters:
      tdigest_array -
      numBuckets -
      nonNullCount -
      Returns:
      An instance of NumericEquiDepthHistogram