summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/ce/histogram_estimation.h
diff options
context:
space:
mode:
authorAlya Berciu <alya.berciu@mongodb.com>2022-09-02 12:40:26 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-02 13:39:17 +0000
commit8581b4968646ea09b703d985c22b08cc01102597 (patch)
treea916997e4044cb0223a4ef483c4ec805353989b6 /src/mongo/db/query/ce/histogram_estimation.h
parent26d222d66fbb97152b283a63f8e6393171c8710f (diff)
downloadmongo-8581b4968646ea09b703d985c22b08cc01102597.tar.gz
SERVER-68445 Integrate histogram bucket interpolation
Co-authored-by: Milena Ivanova <milena.ivanova@mongodb.com> Co-authored-by: Alya Berciu <alya.berciu@mongodb.com>
Diffstat (limited to 'src/mongo/db/query/ce/histogram_estimation.h')
-rw-r--r--src/mongo/db/query/ce/histogram_estimation.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/mongo/db/query/ce/histogram_estimation.h b/src/mongo/db/query/ce/histogram_estimation.h
index b949d0b752e..0e554993983 100644
--- a/src/mongo/db/query/ce/histogram_estimation.h
+++ b/src/mongo/db/query/ce/histogram_estimation.h
@@ -59,7 +59,8 @@ struct EstimationResult {
EstimationResult getTotals(const ScalarHistogram& h);
/**
- * Estimates the cardinality of a predicate of the given type against the histogram.
+ * Compute an estimate for a given value and estimation type. Use linear interpolation for values
+ * that fall inside of histogram buckets.
*/
EstimationResult estimate(const ScalarHistogram& h,
sbe::value::TypeTags tag,
@@ -74,4 +75,26 @@ double estimateIntervalCardinality(const ArrayHistogram& estimator,
const optimizer::IntervalRequirement& interval,
optimizer::CEType inputCardinality);
+/**
+ * Estimates the cardinality of an equality predicate given an ArrayHistogram and an SBE value and
+ * type tag pair.
+ */
+double estimateCardEq(const ArrayHistogram& ah, sbe::value::TypeTags tag, sbe::value::Value val);
+
+/**
+ * Estimates the cardinality of a range predicate given an ArrayHistogram and a range predicate.
+ * Set 'includeScalar' to true to indicate whether or not the provided range should include no-array
+ * values. The other fields define the range of the estimation.
+ */
+double estimateCardRange(const ArrayHistogram& ah,
+ bool includeScalar,
+ /* Define lower bound. */
+ bool lowInclusive,
+ sbe::value::TypeTags tagLow,
+ sbe::value::Value valLow,
+ /* Define upper bound. */
+ bool highInclusive,
+ sbe::value::TypeTags tagHigh,
+ sbe::value::Value valHigh);
+
} // namespace mongo::ce