@@ -1292,8 +1292,7 @@ void Histogram_json::init_for_collection(MEM_ROOT *mem_root,
1292
1292
Histogram_type htype_arg,
1293
1293
ulonglong size_arg)
1294
1294
{
1295
- type= htype_arg;
1296
- // values_ = (uchar*)alloc_root(mem_root, size_arg);
1295
+ DBUG_ASSERT (htype_arg == JSON_HB);
1297
1296
size= (uint8) size_arg;
1298
1297
}
1299
1298
@@ -1302,15 +1301,18 @@ void Histogram_json::init_for_collection(MEM_ROOT *mem_root,
1302
1301
@brief
1303
1302
Parse the histogram from its on-disk representation
1304
1303
1304
+ @return
1305
+ false OK
1306
+ True Error
1305
1307
*/
1306
1308
1307
1309
bool Histogram_json::parse (MEM_ROOT *mem_root, Field *field,
1308
1310
Histogram_type type_arg, const uchar *ptr,
1309
1311
uint size_arg)
1310
1312
{
1311
1313
DBUG_ENTER (" Histogram_json::parse" );
1314
+ DBUG_ASSERT (type_arg == JSON_HB);
1312
1315
size = (uint8) size_arg;
1313
- type = type_arg;
1314
1316
const char *json = (char *)ptr;
1315
1317
int vt;
1316
1318
std::vector<std::string> hist_buckets_text;
@@ -1595,6 +1597,7 @@ void Histogram_json::serialize(Field *field)
1595
1597
field->store ((char *)json_text, strlen ((char *)json_text), &my_charset_bin);
1596
1598
}
1597
1599
1600
+
1598
1601
int Histogram_json::find_bucket (Field *field, const uchar *endpoint)
1599
1602
{
1600
1603
int low = 0 ;
@@ -2061,15 +2064,22 @@ class Histogram_builder_json : public Histogram_builder
2061
2064
}
2062
2065
};
2063
2066
2067
+
2064
2068
Histogram_base *create_histogram (Histogram_type hist_type)
2065
2069
{
2066
- // assumes the caller already checked for invalid histograms
2067
- if (hist_type == JSON_HB)
2068
- return new Histogram_json;
2069
- else
2070
- return new Histogram_binary;
2070
+ switch (hist_type) {
2071
+ case SINGLE_PREC_HB:
2072
+ case DOUBLE_PREC_HB:
2073
+ return new Histogram_binary ();
2074
+ case JSON_HB:
2075
+ return new Histogram_json ();
2076
+ default :
2077
+ DBUG_ASSERT (0 );
2078
+ }
2079
+ return NULL ;
2071
2080
}
2072
2081
2082
+
2073
2083
bool json_get_array_items (const char *json, const char *json_end, int *value_type, std::vector<std::string> &container) {
2074
2084
json_engine_t je;
2075
2085
int vl;
@@ -2255,16 +2265,6 @@ class Count_distinct_field: public Sql_alloc
2255
2265
return distincts_single_occurence;
2256
2266
}
2257
2267
2258
- /*
2259
- @brief
2260
- Get the size of the histogram in bytes built for table_field
2261
- */
2262
- /*
2263
- uint get_hist_size()
2264
- {
2265
- return table_field->collected_stats->histogram.get_size();
2266
- }*/
2267
-
2268
2268
/*
2269
2269
@brief
2270
2270
Get the pointer to the histogram built for table_field
@@ -2916,27 +2916,6 @@ bool Column_statistics_collected::add()
2916
2916
return err;
2917
2917
}
2918
2918
2919
-
2920
- /*
2921
- Create an empty Histogram object from histogram_type.
2922
-
2923
- Note: it is not yet clear whether collection-time histogram should be the same
2924
- as lookup-time histogram. At the moment, they are.
2925
- */
2926
-
2927
- Histogram_base * get_histogram_by_type (MEM_ROOT *mem_root, Histogram_type hist_type) {
2928
- switch (hist_type) {
2929
- case SINGLE_PREC_HB:
2930
- case DOUBLE_PREC_HB:
2931
- return new Histogram_binary ();
2932
- case JSON_HB:
2933
- return new Histogram_json ();
2934
- default :
2935
- DBUG_ASSERT (0 );
2936
- }
2937
- return NULL ;
2938
- };
2939
-
2940
2919
/* *
2941
2920
@brief
2942
2921
Get the results of aggregation when collecting the statistics on a column
@@ -3488,15 +3467,13 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
3488
3467
3489
3468
/* Read statistics from the statistical table column_stats */
3490
3469
stat_table= stat_tables[COLUMN_STAT].table ;
3491
- // ulong total_hist_size= 0;
3492
3470
bool have_histograms= false ;
3493
3471
Column_stat column_stat (stat_table, table);
3494
3472
for (field_ptr= table_share->field ; *field_ptr; field_ptr++)
3495
3473
{
3496
3474
table_field= *field_ptr;
3497
3475
column_stat.set_key_fields (table_field);
3498
3476
column_stat.get_stat_values ();
3499
- // total_hist_size+= table_field->read_stats->histogram.get_size();
3500
3477
if (table_field->read_stats ->histogram_type_on_disk != INVALID_HISTOGRAM)
3501
3478
have_histograms= true ;
3502
3479
}
0 commit comments