Skip to content

Commit 57dd23d

Browse files
drrtuyvuvova
authored andcommitted
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
1 parent 3109d99 commit 57dd23d

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

sql/opt_histogram_json.h

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@
1616

1717
#include "sql_statistics.h"
1818

19+
struct Histogram_bucket
20+
{
21+
// The left endpoint in KeyTupleFormat. The endpoint is inclusive, this
22+
// value is in this bucket.
23+
std::string start_value;
24+
25+
// Cumulative fraction: The fraction of table rows that fall into this
26+
// and preceding buckets.
27+
double cum_fract;
28+
29+
// Number of distinct values in the bucket.
30+
longlong ndv;
31+
};
32+
1933
/*
2034
An equi-height histogram which stores real values for bucket bounds.
2135
@@ -71,21 +85,7 @@ class Histogram_json_hb final : public Histogram_base
7185
/* Collection-time only: collected histogram in the JSON form. */
7286
std::string json_text;
7387

74-
struct Bucket
75-
{
76-
// The left endpoint in KeyTupleFormat. The endpoint is inclusive, this
77-
// value is in this bucket.
78-
std::string start_value;
79-
80-
// Cumulative fraction: The fraction of table rows that fall into this
81-
// and preceding buckets.
82-
double cum_fract;
83-
84-
// Number of distinct values in the bucket.
85-
longlong ndv;
86-
};
87-
88-
std::vector<Bucket> buckets;
88+
std::vector<Histogram_bucket> buckets;
8989

9090
std::string last_bucket_end_endp;
9191

@@ -129,6 +129,16 @@ class Histogram_json_hb final : public Histogram_base
129129
double range_selectivity(Field *field, key_range *min_endp,
130130
key_range *max_endp, double avg_sel) override;
131131

132+
const std::vector<Histogram_bucket>& get_json_histogram() const
133+
{
134+
return buckets;
135+
}
136+
137+
const std::string& get_last_bucket_end_endp() const
138+
{
139+
return last_bucket_end_endp;
140+
}
141+
132142
void set_json_text(ulonglong sz, const char *json_text_arg,
133143
size_t json_text_len)
134144
{

0 commit comments

Comments
 (0)