Class NumericEquiDepthHistogram
java.lang.Object
org.apache.drill.exec.planner.common.NumericEquiDepthHistogram
- All Implemented Interfaces:
Histogram
A column specific equi-depth histogram which is meant for numeric data types
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic NumericEquiDepthHistogram
buildFromTDigest
(byte[] tdigest_array, int numBuckets, long nonNullCount) Build a Numeric Equi-Depth Histogram from a t-digest byte arrayestimatedSelectivity
(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 ...Double[]
int
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 bucketdouble
protected long
getSelectedRows
(org.apache.drill.shaded.guava.com.google.common.collect.Range range, long ndv) protected void
setBucketValue
(int index, Double value) void
setNumRowsPerBucket
(double numRows)
-
Constructor Details
-
NumericEquiDepthHistogram
public NumericEquiDepthHistogram() -
NumericEquiDepthHistogram
public NumericEquiDepthHistogram(int numBuckets)
-
-
Method Details
-
getNumRowsPerBucket
public double getNumRowsPerBucket() -
setNumRowsPerBucket
public void setNumRowsPerBucket(double numRows) -
getBuckets
-
setBucketValue
-
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 interfaceHistogram
- 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
-