1#ifndef HISTOGRAMS_HISTOGRAM_INCLUDED
2#define HISTOGRAMS_HISTOGRAM_INCLUDED
66struct Histogram_comparator;
105 std::map<T, ha_rows, Histogram_comparator, value_map_allocator<T>>;
111 std::map<std::string, Message, std::less<std::string>,
193 return "number-of-buckets-specified";
208 const std::string &tbl_name,
const std::string &col_name,
302 double *selectivity)
const;
432 const std::string &schema_name,
434 const std::string &column_name,
484 double *selectivity)
const;
521 size_t num_buckets,
const std::string &
db_name,
522 const std::string &tbl_name,
523 const std::string &col_name);
596 const char *old_table_name,
const char *new_schema_name,
601 const std::string &column_name,
602 const Histogram **histogram);
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
JSON DOM abstract base class.
Definition: json_dom.h:171
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:369
Mem_root_allocator is a C++ STL memory allocator based on MEM_ROOT.
Definition: mem_root_allocator.h:67
Stateless_allocator is a C++ STL memory allocator skeleton based on Malloc_allocator,...
Definition: stateless_allocator.h:91
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:945
Histogram base class.
Definition: histogram.h:148
virtual std::string histogram_type_to_str() const =0
Returns the histogram type as a readable string.
size_t m_num_buckets_specified
The number of buckets originally specified.
Definition: histogram.h:178
Value_map_type get_data_type() const
Definition: histogram.h:400
double get_equal_to_selectivity_dispatcher(const T &value) const
Definition: histogram.cc:1387
virtual size_t get_num_buckets() const =0
MEM_ROOT * m_mem_root
The MEM_ROOT where the histogram contents will be allocated.
Definition: histogram.h:262
static constexpr const char * data_type_str()
String representation of the JSON field "data-type".
Definition: histogram.h:157
double m_sampling_rate
Definition: histogram.h:169
static constexpr const char * collation_id_str()
String representation of the JSON field "collation-id".
Definition: histogram.h:160
double get_less_than_selectivity_dispatcher(const T &value) const
An internal function for getting the selecitvity estimation.
Definition: histogram.cc:1348
static constexpr const char * buckets_str()
String representation of the JSON field "buckets".
Definition: histogram.h:181
static constexpr const char * numer_of_buckets_specified_str()
String representation of the JSON field "number-of-buckets-specified".
Definition: histogram.h:192
virtual ~Histogram()=default
Destructor.
virtual size_t get_num_distinct_values() const =0
Get the estimated number of distinct non-NULL values.
double get_sampling_rate() const
Definition: histogram.h:377
const enum_histogram_type m_hist_type
The type of this histogram.
Definition: histogram.h:265
virtual bool histogram_to_json(Json_object *json_object) const =0
Converts the histogram to a JSON object.
Definition: histogram.cc:255
double get_non_null_values_frequency() const
Definition: histogram.h:489
const CHARSET_INFO * m_charset
The character set for the data stored.
Definition: histogram.h:175
static constexpr const char * last_updated_str()
String representation of the JSON field "last-updated".
Definition: histogram.h:184
LEX_CSTRING m_table_name
Name of the table this histogram represents.
Definition: histogram.h:274
Histogram(const Histogram &other)=delete
size_t get_num_buckets_specified() const
Definition: histogram.h:406
static constexpr const char * equi_height_str()
String representation of the histogram type EQUI-HEIGHT.
Definition: histogram.h:166
virtual Histogram * clone(MEM_ROOT *mem_root) const =0
Make a clone of the current histogram.
bool get_selectivity(Item **items, size_t item_count, enum_operator op, double *selectivity) const
Get selectivity estimation.
Definition: histogram.cc:1575
double m_null_values_fraction
The fraction of NULL values in the histogram (between 0.0 and 1.0).
Definition: histogram.h:172
const Value_map_type m_data_type
The type of the data this histogram contains.
Definition: histogram.h:268
const LEX_CSTRING get_database_name() const
Definition: histogram.h:351
LEX_CSTRING m_column_name
Name of the column this histogram represents.
Definition: histogram.h:277
bool get_selectivity_dispatcher(Item *item, const enum_operator op, const TYPELIB *typelib, double *selectivity) const
An internal function for getting the selecitvity estimation.
Definition: histogram.cc:1450
double apply_operator(const enum_operator op, const T &value) const
An internal function for applying the correct function for the given operator.
Definition: histogram.cc:1434
const CHARSET_INFO * get_character_set() const
Definition: histogram.h:374
const LEX_CSTRING get_table_name() const
Definition: histogram.h:356
double get_null_values_fraction() const
Definition: histogram.cc:300
MEM_ROOT * get_mem_root() const
Definition: histogram.h:346
enum_histogram_type get_histogram_type() const
Definition: histogram.h:366
LEX_CSTRING m_database_name
Name of the database this histogram represents.
Definition: histogram.h:271
bool store_histogram(THD *thd) const
Store this histogram to persistent storage (data dictionary).
Definition: histogram.cc:1155
static constexpr const char * histogram_type_str()
String representation of the JSON field "histogram-type".
Definition: histogram.h:154
bool histogram_data_type_to_json(Json_object *json_object) const
Write the data type of this histogram into a JSON object.
Definition: histogram.cc:532
static constexpr const char * singleton_str()
String representation of the histogram type SINGLETON.
Definition: histogram.h:163
bool extract_json_dom_value(const Json_dom *json_dom, T *out)
Return the value that is contained in the JSON DOM object.
static constexpr const char * sampling_rate_str()
Definition: histogram.h:189
virtual bool json_to_histogram(const Json_object &json_object)=0
Populate the histogram with data from the provided JSON object.
Definition: histogram.cc:479
double get_greater_than_selectivity_dispatcher(const T &value) const
Definition: histogram.cc:1367
const LEX_CSTRING get_column_name() const
Definition: histogram.h:361
enum_histogram_type
All supported histogram types in MySQL.
Definition: histogram.h:151
static constexpr const char * null_values_str()
String representation of the JSON field "null-values".
Definition: histogram.h:187
static MEM_ROOT mem_root
Definition: client_plugin.cc:109
This file includes constants used by all storage engines.
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
Definition: column_statistics.h:33
std::set< std::string, std::less< std::string >, Histogram_key_allocator< std::string > > columns_set
Definition: histogram.h:108
bool drop_histograms(THD *thd, TABLE_LIST &table, const columns_set &columns, bool needs_lock, results_map &results)
Drop histograms for a set of columns in a given table.
Definition: histogram.cc:1071
std::map< std::string, Message, std::less< std::string >, Histogram_key_allocator< std::pair< const std::string, Message > > > results_map
Definition: histogram.h:112
Message
Definition: histogram.h:79
@ COVERED_BY_SINGLE_PART_UNIQUE_INDEX
@ MULTIPLE_TABLES_SPECIFIED
enum_operator
The different operators we can ask histogram statistics for selectivity estimations.
Definition: histogram.h:118
bool rename_histograms(THD *thd, const char *old_schema_name, const char *old_table_name, const char *new_schema_name, const char *new_table_name, results_map &results)
Rename histograms for all columns in a given table.
Definition: histogram.cc:1286
Histogram * build_histogram(MEM_ROOT *mem_root, const Value_map< T > &value_map, size_t num_buckets, const std::string &db_name, const std::string &tbl_name, const std::string &col_name)
Create a histogram from a value map.
Definition: histogram.cc:310
bool find_histogram(THD *thd, const std::string &schema_name, const std::string &table_name, const std::string &column_name, const Histogram **histogram)
Definition: histogram.cc:1325
bool drop_all_histograms(THD *thd, TABLE_LIST &table, const dd::Table &table_definition, results_map &results)
Drop histograms for all columns in a given table.
Definition: histogram.cc:1061
static const double INVALID_NULL_VALUES_FRACTION
The default (and invalid) value for "m_null_values_fraction".
Definition: histogram.h:77
std::map< T, ha_rows, Histogram_comparator, value_map_allocator< T > > value_map_type
Definition: histogram.h:105
bool update_histogram(THD *thd, TABLE_LIST *table, const columns_set &columns, int num_buckets, results_map &results)
Create or update histograms for a set of columns of a given table.
Definition: histogram.cc:874
Value_map_type
Datatypes that a Value_map and histogram can hold (including the invalid type).
Definition: value_map_type.h:32
const char * table_name
Definition: rules_table_service.cc:55
const char * db_name
Definition: rules_table_service.cc:54
required string type
Definition: replication_group_member_actions.proto:33
Definition: m_ctype.h:354
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
Definition: mysql_lex_string.h:39
Definition: histogram.h:93
void * operator()(size_t s) const
Definition: histogram.cc:99