Commit 2aca7b0c authored by Michael Okoko's avatar Michael Okoko Committed by Sergei Petrunia

Prepare JSON as valid histogram_type

Signed-off-by: default avatarMichael Okoko <okokomichaels@outlook.com>
parent e222e44d
...@@ -314,7 +314,7 @@ DROP TABLE tmp_proxies_priv; ...@@ -314,7 +314,7 @@ DROP TABLE tmp_proxies_priv;
CREATE TABLE IF NOT EXISTS table_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, cardinality bigint(21) unsigned DEFAULT NULL, PRIMARY KEY (db_name,table_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Tables'; CREATE TABLE IF NOT EXISTS table_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, cardinality bigint(21) unsigned DEFAULT NULL, PRIMARY KEY (db_name,table_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Tables';
CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varbinary(255) DEFAULT NULL, max_value varbinary(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, hist_size tinyint unsigned, hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB'), histogram varbinary(255), PRIMARY KEY (db_name,table_name,column_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns'; CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varbinary(255) DEFAULT NULL, max_value varbinary(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, hist_size tinyint unsigned, hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON'), histogram varbinary(255), PRIMARY KEY (db_name,table_name,column_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
CREATE TABLE IF NOT EXISTS index_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, index_name varchar(64) NOT NULL, prefix_arity int(11) unsigned NOT NULL, avg_frequency decimal(12,4) DEFAULT NULL, PRIMARY KEY (db_name,table_name,index_name,prefix_arity) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Indexes'; CREATE TABLE IF NOT EXISTS index_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, index_name varchar(64) NOT NULL, prefix_arity int(11) unsigned NOT NULL, avg_frequency decimal(12,4) DEFAULT NULL, PRIMARY KEY (db_name,table_name,index_name,prefix_arity) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Indexes';
......
...@@ -503,7 +503,7 @@ String *Item_func_from_base64::val_str(String *str) ...@@ -503,7 +503,7 @@ String *Item_func_from_base64::val_str(String *str)
const char *histogram_types[] = const char *histogram_types[] =
{"SINGLE_PREC_HB", "DOUBLE_PREC_HB", 0}; {"SINGLE_PREC_HB", "DOUBLE_PREC_HB", "JSON", 0};
static TYPELIB histogram_types_typelib= static TYPELIB histogram_types_typelib=
{ array_elements(histogram_types), { array_elements(histogram_types),
"histogram_types", "histogram_types",
......
...@@ -178,7 +178,7 @@ TABLE_FIELD_TYPE column_stat_fields[COLUMN_STAT_N_FIELDS] = ...@@ -178,7 +178,7 @@ TABLE_FIELD_TYPE column_stat_fields[COLUMN_STAT_N_FIELDS] =
}, },
{ {
{ STRING_WITH_LEN("hist_type") }, { STRING_WITH_LEN("hist_type") },
{ STRING_WITH_LEN("enum('SINGLE_PREC_HB','DOUBLE_PREC_HB')") }, { STRING_WITH_LEN("enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON')") },
{ STRING_WITH_LEN("utf8mb3") } { STRING_WITH_LEN("utf8mb3") }
}, },
{ {
...@@ -1070,8 +1070,12 @@ class Column_stat: public Stat_table ...@@ -1070,8 +1070,12 @@ class Column_stat: public Stat_table
stat_field->store(stats->histogram.get_type() + 1); stat_field->store(stats->histogram.get_type() + 1);
break; break;
case COLUMN_STAT_HISTOGRAM: case COLUMN_STAT_HISTOGRAM:
stat_field->store((char *)stats->histogram.get_values(), if (stats->histogram.get_type() == JSON) {
stat_field->store((char *) "hello_world", 11, &my_charset_bin);
} else {
stat_field->store((char *) stats->histogram.get_values(),
stats->histogram.get_size(), &my_charset_bin); stats->histogram.get_size(), &my_charset_bin);
}
break; break;
} }
} }
......
...@@ -42,7 +42,8 @@ typedef ...@@ -42,7 +42,8 @@ typedef
enum enum_histogram_type enum enum_histogram_type
{ {
SINGLE_PREC_HB, SINGLE_PREC_HB,
DOUBLE_PREC_HB DOUBLE_PREC_HB,
JSON
} Histogram_type; } Histogram_type;
enum enum_stat_tables enum enum_stat_tables
...@@ -154,6 +155,7 @@ class Histogram ...@@ -154,6 +155,7 @@ class Histogram
case SINGLE_PREC_HB: case SINGLE_PREC_HB:
return ((uint) (1 << 8) - 1); return ((uint) (1 << 8) - 1);
case DOUBLE_PREC_HB: case DOUBLE_PREC_HB:
case JSON:
return ((uint) (1 << 16) - 1); return ((uint) (1 << 16) - 1);
} }
return 1; return 1;
...@@ -166,6 +168,7 @@ class Histogram ...@@ -166,6 +168,7 @@ class Histogram
case SINGLE_PREC_HB: case SINGLE_PREC_HB:
return size; return size;
case DOUBLE_PREC_HB: case DOUBLE_PREC_HB:
case JSON:
return size / 2; return size / 2;
} }
return 0; return 0;
...@@ -179,6 +182,7 @@ class Histogram ...@@ -179,6 +182,7 @@ class Histogram
case SINGLE_PREC_HB: case SINGLE_PREC_HB:
return (uint) (((uint8 *) values)[i]); return (uint) (((uint8 *) values)[i]);
case DOUBLE_PREC_HB: case DOUBLE_PREC_HB:
case JSON:
return (uint) uint2korr(values + i * 2); return (uint) uint2korr(values + i * 2);
} }
return 0; return 0;
...@@ -254,6 +258,7 @@ class Histogram ...@@ -254,6 +258,7 @@ class Histogram
{ {
switch (type) { switch (type) {
case SINGLE_PREC_HB: case SINGLE_PREC_HB:
case JSON:
((uint8 *) values)[i]= (uint8) (val * prec_factor()); ((uint8 *) values)[i]= (uint8) (val * prec_factor());
return; return;
case DOUBLE_PREC_HB: case DOUBLE_PREC_HB:
...@@ -266,6 +271,7 @@ class Histogram ...@@ -266,6 +271,7 @@ class Histogram
{ {
switch (type) { switch (type) {
case SINGLE_PREC_HB: case SINGLE_PREC_HB:
case JSON:
((uint8 *) values)[i]= ((uint8 *) values)[i-1]; ((uint8 *) values)[i]= ((uint8 *) values)[i-1];
return; return;
case DOUBLE_PREC_HB: case DOUBLE_PREC_HB:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment