Commit ce4956f3 authored by Sergei Petrunia's avatar Sergei Petrunia

Code cleanup

parent f7e49c98
...@@ -282,15 +282,6 @@ int json_key_matches(json_engine_t *je, json_string_t *k); ...@@ -282,15 +282,6 @@ int json_key_matches(json_engine_t *je, json_string_t *k);
*/ */
int json_read_value(json_engine_t *j); int json_read_value(json_engine_t *j);
/*
json_smart_read_value() reads a JSON value. Pointer to value is stored in
*value and its length in *value_len.
if the value is non a scalar, it returns pointers to its JSON
representation.
The function should only be called when je->state==JST_VALUE.
*/
enum json_types json_smart_read_value(json_engine_t *je, const char **value, int *value_len);
/* /*
json_skip_key() makes parser skip the content of the current json_skip_key() makes parser skip the content of the current
......
# The time on ANALYSE FORMAT=JSON is rather variable # Remove non-deterministic parts of JSON_HB histogram
--replace_regex /("(collected_at|collected_by)": )"[^"]*"/\1"REPLACED"/ --replace_regex /("(collected_at|collected_by)": )"[^"]*"/\1"REPLACED"/
...@@ -914,7 +914,7 @@ double position_in_interval(Field *field, const uchar *key, uint key_len, ...@@ -914,7 +914,7 @@ double position_in_interval(Field *field, const uchar *key, uint key_len,
double Histogram_json_hb::point_selectivity(Field *field, key_range *endpoint, double Histogram_json_hb::point_selectivity(Field *field, key_range *endpoint,
double avg_sel, double total_rows) double avg_sel)
{ {
const uchar *key = endpoint->key; const uchar *key = endpoint->key;
if (field->real_maybe_null()) if (field->real_maybe_null())
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
] ]
} }
The histogram is an object with single member named Histogram_json_hb:: Histogram is a JSON object. It has some global properties and "histogram_hb"
JSON_NAME. The value of that member is an array of buckets. member whose value is a JSON array of histogram buckets.
Each bucket is an object with these members: Each bucket is an object with these members:
"start" - the first value in the bucket. "start" - the first value in the bucket.
...@@ -126,8 +126,7 @@ class Histogram_json_hb : public Histogram_base ...@@ -126,8 +126,7 @@ class Histogram_json_hb : public Histogram_base
ulonglong size) override; ulonglong size) override;
double point_selectivity(Field *field, key_range *endpoint, double point_selectivity(Field *field, key_range *endpoint,
double avg_selection, double avg_sel) override;
double total_rows) override;
double range_selectivity(Field *field, key_range *min_endp, double range_selectivity(Field *field, key_range *min_endp,
key_range *max_endp, double avg_sel) override; key_range *max_endp, double avg_sel) override;
......
...@@ -3894,8 +3894,7 @@ double get_column_range_cardinality(Field *field, ...@@ -3894,8 +3894,7 @@ double get_column_range_cardinality(Field *field,
{ {
res= col_non_nulls * res= col_non_nulls *
hist->point_selectivity(field, min_endp, hist->point_selectivity(field, min_endp,
avg_frequency / col_non_nulls, avg_frequency / col_non_nulls);
tab_records);
} }
} }
else if (avg_frequency == 0.0) else if (avg_frequency == 0.0)
...@@ -3989,8 +3988,7 @@ double get_column_range_cardinality(Field *field, ...@@ -3989,8 +3988,7 @@ double get_column_range_cardinality(Field *field,
*/ */
double Histogram_binary::point_selectivity(Field *field, key_range *endpoint, double Histogram_binary::point_selectivity(Field *field, key_range *endpoint,
double avg_sel, double avg_sel)
double total_records)
{ {
double sel; double sel;
Column_statistics *col_stats= field->read_stats; Column_statistics *col_stats= field->read_stats;
......
...@@ -188,8 +188,7 @@ class Histogram_base ...@@ -188,8 +188,7 @@ class Histogram_base
virtual double point_selectivity(Field *field, key_range *endpoint, virtual double point_selectivity(Field *field, key_range *endpoint,
double avg_selectivity, double avg_sel)=0;
double total_rows)=0;
virtual double range_selectivity(Field *field, key_range *min_endp, virtual double range_selectivity(Field *field, key_range *min_endp,
key_range *max_endp, double avg_sel)=0; key_range *max_endp, double avg_sel)=0;
...@@ -359,8 +358,7 @@ class Histogram_binary : public Histogram_base ...@@ -359,8 +358,7 @@ class Histogram_binary : public Histogram_base
Estimate selectivity of "col=const" using a histogram Estimate selectivity of "col=const" using a histogram
*/ */
double point_selectivity(Field *field, key_range *endpoint, double point_selectivity(Field *field, key_range *endpoint,
double avg_sel, double avg_sel) override;
double total_rows) override;
}; };
......
...@@ -1868,8 +1868,8 @@ int json_path_compare(const json_path_t *a, const json_path_t *b, ...@@ -1868,8 +1868,8 @@ int json_path_compare(const json_path_t *a, const json_path_t *b,
} }
enum json_types json_smart_read_value(json_engine_t *je, static enum json_types smart_read_value(json_engine_t *je,
const char **value, int *value_len) const char **value, int *value_len)
{ {
if (json_read_value(je)) if (json_read_value(je))
goto err_return; goto err_return;
...@@ -1909,7 +1909,7 @@ enum json_types json_type(const char *js, const char *js_end, ...@@ -1909,7 +1909,7 @@ enum json_types json_type(const char *js, const char *js_end,
json_scan_start(&je, &my_charset_utf8mb4_bin,(const uchar *) js, json_scan_start(&je, &my_charset_utf8mb4_bin,(const uchar *) js,
(const uchar *) js_end); (const uchar *) js_end);
return json_smart_read_value(&je, value, value_len); return smart_read_value(&je, value, value_len);
} }
...@@ -1933,7 +1933,7 @@ enum json_types json_get_array_item(const char *js, const char *js_end, ...@@ -1933,7 +1933,7 @@ enum json_types json_get_array_item(const char *js, const char *js_end,
{ {
case JST_VALUE: case JST_VALUE:
if (c_item == n_item) if (c_item == n_item)
return json_smart_read_value(&je, value, value_len); return smart_read_value(&je, value, value_len);
if (json_skip_key(&je)) if (json_skip_key(&je))
goto err_return; goto err_return;
...@@ -1998,7 +1998,7 @@ enum json_types json_get_object_key(const char *js, const char *js_end, ...@@ -1998,7 +1998,7 @@ enum json_types json_get_object_key(const char *js, const char *js_end,
json_string_set_str(&key_name, (const uchar *) key, json_string_set_str(&key_name, (const uchar *) key,
(const uchar *) key_end); (const uchar *) key_end);
if (json_key_matches(&je, &key_name)) if (json_key_matches(&je, &key_name))
return json_smart_read_value(&je, value, value_len); return smart_read_value(&je, value, value_len);
if (json_skip_key(&je)) if (json_skip_key(&je))
goto err_return; goto err_return;
......
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