summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2021-08-31 00:53:09 +0300
committerSergei Petrunia <psergey@askmonty.org>2021-08-31 00:53:09 +0300
commit337282286b43f9278a78b0fe062fd2439f7db9ce (patch)
treedcd43090e385e4fed768e65b53ca8173ded0fb0d
parent18f3ac5f43260ca6e4f03bba567b31a4eb4cf18e (diff)
downloadmariadb-git-337282286b43f9278a78b0fe062fd2439f7db9ce.tar.gz
Code cleanup + reduce the diff size
-rw-r--r--sql/sql_statistics.cc20
-rw-r--r--sql/sql_statistics.h44
2 files changed, 27 insertions, 37 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 3fba18f221b..a19a179b0e4 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -3620,16 +3620,6 @@ int read_histograms_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
if (stats_cb->start_histograms_load())
{
- //uchar *histogram= (uchar *) alloc_root(&stats_cb->mem_root,
- // stats_cb->total_hist_size);
- /*
- if (!histogram)
- {
- stats_cb->abort_histograms_load();
- DBUG_RETURN(1);
- }
- */
-
Column_stat column_stat(stat_tables[COLUMN_STAT].table, table);
for (Field **field_ptr= table->s->field; *field_ptr; field_ptr++)
{
@@ -4393,10 +4383,9 @@ double get_column_range_cardinality(Field *field,
/*
Estimate selectivity of "col=const" using a histogram
- @param field - the field to estimate its selectivity.
+ @param field the field to estimate its selectivity.
- @param min_endp, max_endp - Specifies the left and right bounds. For point selectivity,
- they are both equal.
+ @param endpoint The constant
@param avg_sel Average selectivity of condition "col=const" in this table.
It is calcuated as (#non_null_values / #distinct_values).
@@ -4426,11 +4415,12 @@ double get_column_range_cardinality(Field *field,
value.
*/
-double Histogram_binary::point_selectivity(Field *field, key_range *min_endp, double avg_sel)
+double Histogram_binary::point_selectivity(Field *field, key_range *endpoint,
+ double avg_sel)
{
double sel;
Column_statistics *col_stats= field->read_stats;
- store_key_image_to_rec(field, (uchar *) min_endp->key,
+ store_key_image_to_rec(field, (uchar *) endpoint->key,
field->key_length());
double pos= field->pos_in_interval(col_stats->min_value,
col_stats->max_value);
diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h
index 6fb82340a70..cc1028c238a 100644
--- a/sql/sql_statistics.h
+++ b/sql/sql_statistics.h
@@ -195,26 +195,6 @@ private:
class Histogram_binary : public Histogram_base
{
-public:
- bool parse(MEM_ROOT *mem_root, Field *, Histogram_type type_arg,
- const char *hist_data, size_t hist_data_len) override;
- void serialize(Field *to_field) override;
-
- Histogram_type get_type() override { return type; }
-
- uint get_width() override
- {
- switch (type) {
- case SINGLE_PREC_HB:
- return size;
- case DOUBLE_PREC_HB:
- return size / 2;
- default:
- DBUG_ASSERT(0);
- }
- return 0;
- }
-
private:
Histogram_type type;
uint8 size; /* Size of values array, in bytes */
@@ -233,6 +213,20 @@ private:
return 1;
}
+public:
+ uint get_width() override
+ {
+ switch (type) {
+ case SINGLE_PREC_HB:
+ return size;
+ case DOUBLE_PREC_HB:
+ return size / 2;
+ default:
+ DBUG_ASSERT(0);
+ }
+ return 0;
+ }
+private:
uint get_value(uint i)
{
DBUG_ASSERT(i < get_width());
@@ -287,10 +281,16 @@ private:
}
public:
- void init_for_collection(MEM_ROOT *mem_root, Histogram_type htype_arg, ulonglong size) override;
-
uint get_size() override {return (uint)size;}
+ Histogram_type get_type() override { return type; }
+
+ bool parse(MEM_ROOT *mem_root, Field *, Histogram_type type_arg,
+ const char *hist_data, size_t hist_data_len) override;
+ void serialize(Field *to_field) override;
+ void init_for_collection(MEM_ROOT *mem_root, Histogram_type htype_arg,
+ ulonglong size) override;
+
bool is_available() override { return (values!=NULL); }
/*