|
16 | 16 |
|
17 | 17 | #include "sql_statistics.h"
|
18 | 18 |
|
| 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 | + |
19 | 33 | /*
|
20 | 34 | An equi-height histogram which stores real values for bucket bounds.
|
21 | 35 |
|
@@ -71,21 +85,7 @@ class Histogram_json_hb final : public Histogram_base
|
71 | 85 | /* Collection-time only: collected histogram in the JSON form. */
|
72 | 86 | std::string json_text;
|
73 | 87 |
|
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; |
89 | 89 |
|
90 | 90 | std::string last_bucket_end_endp;
|
91 | 91 |
|
@@ -129,6 +129,16 @@ class Histogram_json_hb final : public Histogram_base
|
129 | 129 | double range_selectivity(Field *field, key_range *min_endp,
|
130 | 130 | key_range *max_endp, double avg_sel) override;
|
131 | 131 |
|
| 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 | + |
132 | 142 | void set_json_text(ulonglong sz, const char *json_text_arg,
|
133 | 143 | size_t json_text_len)
|
134 | 144 | {
|
|
0 commit comments