@@ -1292,8 +1292,7 @@ void Histogram_json::init_for_collection(MEM_ROOT *mem_root,
12921292 Histogram_type htype_arg,
12931293 ulonglong size_arg)
12941294{
1295- type= htype_arg;
1296- // values_ = (uchar*)alloc_root(mem_root, size_arg);
1295+ DBUG_ASSERT (htype_arg == JSON_HB);
12971296 size= (uint8) size_arg;
12981297}
12991298
@@ -1302,15 +1301,18 @@ void Histogram_json::init_for_collection(MEM_ROOT *mem_root,
13021301 @brief
13031302 Parse the histogram from its on-disk representation
13041303
1304+ @return
1305+ false OK
1306+ True Error
13051307*/
13061308
13071309bool Histogram_json::parse (MEM_ROOT *mem_root, Field *field,
13081310 Histogram_type type_arg, const uchar *ptr,
13091311 uint size_arg)
13101312{
13111313 DBUG_ENTER (" Histogram_json::parse" );
1314+ DBUG_ASSERT (type_arg == JSON_HB);
13121315 size = (uint8) size_arg;
1313- type = type_arg;
13141316 const char *json = (char *)ptr;
13151317 int vt;
13161318 std::vector<std::string> hist_buckets_text;
@@ -1595,6 +1597,7 @@ void Histogram_json::serialize(Field *field)
15951597 field->store ((char *)json_text, strlen ((char *)json_text), &my_charset_bin);
15961598}
15971599
1600+
15981601int Histogram_json::find_bucket (Field *field, const uchar *endpoint)
15991602{
16001603 int low = 0 ;
@@ -2061,15 +2064,22 @@ class Histogram_builder_json : public Histogram_builder
20612064 }
20622065};
20632066
2067+
20642068Histogram_base *create_histogram (Histogram_type hist_type)
20652069{
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 ;
20712080}
20722081
2082+
20732083bool json_get_array_items (const char *json, const char *json_end, int *value_type, std::vector<std::string> &container) {
20742084 json_engine_t je;
20752085 int vl;
@@ -2255,16 +2265,6 @@ class Count_distinct_field: public Sql_alloc
22552265 return distincts_single_occurence;
22562266 }
22572267
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-
22682268 /*
22692269 @brief
22702270 Get the pointer to the histogram built for table_field
@@ -2916,27 +2916,6 @@ bool Column_statistics_collected::add()
29162916 return err;
29172917}
29182918
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-
29402919/* *
29412920 @brief
29422921 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)
34883467
34893468 /* Read statistics from the statistical table column_stats */
34903469 stat_table= stat_tables[COLUMN_STAT].table ;
3491- // ulong total_hist_size= 0;
34923470 bool have_histograms= false ;
34933471 Column_stat column_stat (stat_table, table);
34943472 for (field_ptr= table_share->field ; *field_ptr; field_ptr++)
34953473 {
34963474 table_field= *field_ptr;
34973475 column_stat.set_key_fields (table_field);
34983476 column_stat.get_stat_values ();
3499- // total_hist_size+= table_field->read_stats->histogram.get_size();
35003477 if (table_field->read_stats ->histogram_type_on_disk != INVALID_HISTOGRAM)
35013478 have_histograms= true ;
35023479 }
0 commit comments