New getter to read Engine Independent JSON histogram buckets directly

This would allow Columnstore to leverage EI data in its cost-based and rewrite optimizer parts
This commit is contained in:
drrtuy 2025-06-02 12:26:25 +00:00
parent 9bf0492b7d
commit d5580feab7
2 changed files with 26 additions and 15 deletions

View File

@ -71,21 +71,7 @@ class Histogram_json_hb final : public Histogram_base
/* Collection-time only: collected histogram in the JSON form. */
std::string json_text;
struct Bucket
{
// The left endpoint in KeyTupleFormat. The endpoint is inclusive, this
// value is in this bucket.
std::string start_value;
// Cumulative fraction: The fraction of table rows that fall into this
// and preceding buckets.
double cum_fract;
// Number of distinct values in the bucket.
longlong ndv;
};
std::vector<Bucket> buckets;
std::vector<Histogram_bucket> buckets;
std::string last_bucket_end_endp;
@ -129,6 +115,11 @@ public:
double range_selectivity(Field *field, key_range *min_endp,
key_range *max_endp, double avg_sel) override;
std::vector<Histogram_bucket> get_histogram() override
{
return buckets;
}
void set_json_text(ulonglong sz, const char *json_text_arg,
size_t json_text_len)
{

View File

@ -152,6 +152,19 @@ bool is_stat_table(const LEX_CSTRING *db, LEX_CSTRING *table);
bool is_eits_usable(Field* field);
class Histogram_builder;
struct Histogram_bucket
{
// The left endpoint in KeyTupleFormat. The endpoint is inclusive, this
// value is in this bucket.
std::string start_value;
// Cumulative fraction: The fraction of table rows that fall into this
// and preceding buckets.
double cum_fract;
// Number of distinct values in the bucket.
longlong ndv;
};
/*
Common base for all histograms
@ -199,6 +212,8 @@ public:
double avg_sel)=0;
virtual double range_selectivity(Field *field, key_range *min_endp,
key_range *max_endp, double avg_sel)=0;
virtual std::vector<Histogram_bucket> get_histogram()=0;
/*
Legacy: return the size of the histogram on disk.
@ -355,6 +370,11 @@ public:
*/
double point_selectivity(Field *field, key_range *endpoint,
double avg_sel) override;
std::vector<Histogram_bucket> get_histogram() override
{
return {};
}
};