Code cleanup + reduce the diff size
This commit is contained in:
parent
229c836d6a
commit
3486bf4110
@ -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);
|
||||
|
@ -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); }
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user