![]() |
MySQL 8.0.43
Source Code Documentation
|
#include <singleton.h>
Public Member Functions | |
| Histogram * | clone (MEM_ROOT *mem_root) const override |
| Make a clone of this histogram on a MEM_ROOT. More... | |
| Singleton (const Singleton< T > &other)=delete | |
| bool | build_histogram (const Value_map< T > &value_map, size_t num_buckets) |
| Build the Singleton histogram. More... | |
| bool | histogram_to_json (Json_object *json_object) const override |
| Convert this histogram to a JSON object. More... | |
| size_t | get_num_buckets () const override |
| size_t | get_num_distinct_values () const override |
| Get the estimated number of distinct non-NULL values. More... | |
| std::string | histogram_type_to_str () const override |
| Returns the histogram type as a readable string. More... | |
| double | get_equal_to_selectivity (const T &value) const |
| Find the number of values equal to 'value'. More... | |
| double | get_less_than_selectivity (const T &value) const |
| Find the number of values less than 'value'. More... | |
| double | get_greater_than_selectivity (const T &value) const |
| Find the number of values greater than 'value'. More... | |
| Singleton (MEM_ROOT *mem_root, const Singleton< String > &other, bool *error) | |
Public Member Functions inherited from histograms::Histogram | |
| Histogram ()=delete | |
| Histogram (const Histogram &other)=delete | |
| virtual | ~Histogram ()=default |
| Destructor. More... | |
| MEM_ROOT * | get_mem_root () const |
| const LEX_CSTRING | get_database_name () const |
| const LEX_CSTRING | get_table_name () const |
| const LEX_CSTRING | get_column_name () const |
| enum_histogram_type | get_histogram_type () const |
| double | get_null_values_fraction () const |
| const CHARSET_INFO * | get_character_set () const |
| double | get_sampling_rate () const |
| Value_map_type | get_data_type () const |
| size_t | get_num_buckets_specified () const |
| bool | store_histogram (THD *thd) const |
| Store this histogram to persistent storage (data dictionary). More... | |
| bool | get_selectivity (Item **items, size_t item_count, enum_operator op, double *selectivity) const |
| Get selectivity estimation. More... | |
| double | get_non_null_values_fraction () const |
| template<> | |
| bool | extract_json_dom_value (const Json_dom *json_dom, double *out, Error_context *context) |
| template<> | |
| bool | extract_json_dom_value (const Json_dom *json_dom, String *out, Error_context *context) |
| template<> | |
| bool | extract_json_dom_value (const Json_dom *json_dom, ulonglong *out, Error_context *context) |
| template<> | |
| bool | extract_json_dom_value (const Json_dom *json_dom, longlong *out, Error_context *context) |
| template<> | |
| bool | extract_json_dom_value (const Json_dom *json_dom, MYSQL_TIME *out, Error_context *context) |
| template<> | |
| bool | extract_json_dom_value (const Json_dom *json_dom, my_decimal *out, Error_context *context) |
Static Public Member Functions | |
| static Singleton< T > * | create (MEM_ROOT *mem_root, const std::string &db_name, const std::string &tbl_name, const std::string &col_name, Value_map_type data_type) |
| Singleton histogram factory method. More... | |
Static Public Member Functions inherited from histograms::Histogram | |
| static constexpr const char * | histogram_type_str () |
| String representation of the JSON field "histogram-type". More... | |
| static constexpr const char * | data_type_str () |
| String representation of the JSON field "data-type". More... | |
| static constexpr const char * | collation_id_str () |
| String representation of the JSON field "collation-id". More... | |
| static constexpr const char * | singleton_str () |
| String representation of the histogram type SINGLETON. More... | |
| static constexpr const char * | equi_height_str () |
| String representation of the histogram type EQUI-HEIGHT. More... | |
| static Histogram * | json_to_histogram (MEM_ROOT *mem_root, const std::string &schema_name, const std::string &table_name, const std::string &column_name, const Json_object &json_object, Error_context *context) |
| Converts JSON object to a histogram. More... | |
Protected Member Functions | |
| bool | json_to_histogram (const Json_object &json_object, Error_context *context) override |
| Populate this histogram with contents from a JSON object. More... | |
Protected Member Functions inherited from histograms::Histogram | |
| Histogram (MEM_ROOT *mem_root, const std::string &db_name, const std::string &tbl_name, const std::string &col_name, enum_histogram_type type, Value_map_type data_type, bool *error) | |
| Constructor. More... | |
| Histogram (MEM_ROOT *mem_root, const Histogram &other, bool *error) | |
| Copy constructor. More... | |
| bool | histogram_data_type_to_json (Json_object *json_object) const |
| Write the data type of this histogram into a JSON object. More... | |
| template<class T > | |
| bool | extract_json_dom_value (const Json_dom *json_dom, T *out, Error_context *context) |
| Return the value that is contained in the JSON DOM object. More... | |
Private Member Functions | |
| Singleton (MEM_ROOT *mem_root, const std::string &db_name, const std::string &tbl_name, const std::string &col_name, Value_map_type data_type, bool *error) | |
| Singleton constructor. More... | |
| Singleton (MEM_ROOT *mem_root, const Singleton< T > &other, bool *error) | |
| Singleton copy-constructor. More... | |
| bool | add_value_json_bucket (const double &value, Json_array *json_bucket) |
| bool | add_value_json_bucket (const String &value, Json_array *json_bucket) |
| bool | add_value_json_bucket (const ulonglong &value, Json_array *json_bucket) |
| bool | add_value_json_bucket (const longlong &value, Json_array *json_bucket) |
| bool | add_value_json_bucket (const MYSQL_TIME &value, Json_array *json_bucket) |
| bool | add_value_json_bucket (const my_decimal &value, Json_array *json_bucket) |
Static Private Member Functions | |
| static constexpr const char * | singleton_str () |
| String representation of the histogram type SINGLETON. More... | |
| static bool | add_value_json_bucket (const T &value, Json_array *json_bucket) |
| Add value to a JSON bucket. More... | |
| static bool | create_json_bucket (const SingletonBucket< T > &bucket, Json_array *json_bucket) |
| Convert one bucket to a JSON object. More... | |
Private Attributes | |
| Mem_root_array< SingletonBucket< T > > | m_buckets |
| The buckets for this histogram [value, cumulative frequency]. More... | |
Additional Inherited Members | |
Public Types inherited from histograms::Histogram | |
| enum class | enum_histogram_type { EQUI_HEIGHT , SINGLETON } |
| All supported histogram types in MySQL. More... | |
Static Protected Member Functions inherited from histograms::Histogram | |
| static constexpr const char * | buckets_str () |
| String representation of the JSON field "buckets". More... | |
| static constexpr const char * | last_updated_str () |
| String representation of the JSON field "last-updated". More... | |
| static constexpr const char * | null_values_str () |
| String representation of the JSON field "null-values". More... | |
| static constexpr const char * | sampling_rate_str () |
| static constexpr const char * | numer_of_buckets_specified_str () |
| String representation of the JSON field "number-of-buckets-specified". More... | |
Protected Attributes inherited from histograms::Histogram | |
| double | m_sampling_rate |
| double | m_null_values_fraction |
| The fraction of NULL values in the histogram (between 0.0 and 1.0). More... | |
| const CHARSET_INFO * | m_charset |
| The character set for the data stored. More... | |
| size_t | m_num_buckets_specified |
| The number of buckets originally specified. More... | |
|
delete |
|
private |
Singleton constructor.
This will not build the histogram, but only set its properties.
| mem_root | the mem_root where the histogram contents will be allocated | |
| db_name | name of the database this histogram represents | |
| tbl_name | name of the table this histogram represents | |
| col_name | name of the column this histogram represents | |
| data_type | the type of data that this histogram contains | |
| [out] | error | is set to true if an error occurs |
|
private |
Singleton copy-constructor.
This will take a copy of the histogram and all of its contents on the provided MEM_ROOT.
| mem_root | the MEM_ROOT to allocate the new histogram on. | |
| other | the histogram to take a copy of | |
| [out] | error | is set to true if an error occurs |
| histograms::Singleton< String >::Singleton | ( | MEM_ROOT * | mem_root, |
| const Singleton< String > & | other, | ||
| bool * | error | ||
| ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
Add value to a JSON bucket.
This function adds the value to the supplied JSON array.
| value | the value to add | |
| [out] | json_bucket | a JSON array where the bucket data is to be stored |
|
private |
| bool histograms::Singleton< T >::build_histogram | ( | const Value_map< T > & | value_map, |
| size_t | num_buckets | ||
| ) |
Build the Singleton histogram.
| value_map | values to create the histogram for |
| num_buckets | the number of buckets specified/requested by the user |
|
overridevirtual |
Make a clone of this histogram on a MEM_ROOT.
| mem_root | the MEM_ROOT to allocate the new histogram contents on. |
Implements histograms::Histogram.
|
static |
Singleton histogram factory method.
Attempts to allocate and initialize a singleton histogram on the supplied mem_root. This will not build the histogram, but only set its properties. If the attempt to allocate the histogram fails or if an error occurs during construction we return nullptr.
| mem_root | the mem_root where the histogram contents will be allocated |
| db_name | name of the database this histogram represents |
| tbl_name | name of the table this histogram represents |
| col_name | name of the column this histogram represents |
| data_type | the type of data that this histogram contains |
|
staticprivate |
Convert one bucket to a JSON object.
| bucket | the histogram bucket to convert | |
| [out] | json_bucket | a JSON array where the bucket data is to be stored |
| double histograms::Singleton< T >::get_equal_to_selectivity | ( | const T & | value | ) | const |
Find the number of values equal to 'value'.
This function will estimate the number of values that is equal to the provided value.
| value | The value to estimate the selectivity for. |
| double histograms::Singleton< T >::get_greater_than_selectivity | ( | const T & | value | ) | const |
Find the number of values greater than 'value'.
This function will estimate the number of values that is greater than the provided value.
| value | The value to estimate the selectivity for. |
| double histograms::Singleton< T >::get_less_than_selectivity | ( | const T & | value | ) | const |
Find the number of values less than 'value'.
This function will estimate the number of values that is less than the provided value.
| value | The value to estimate the selectivity for. |
|
inlineoverridevirtual |
Implements histograms::Histogram.
|
inlineoverridevirtual |
Get the estimated number of distinct non-NULL values.
TODO(christiani): If the histogram is based on sampling, then this estimate is potentially off by a factor 1/sampling_rate. It should be adjusted to an actual estimate if we are going to use it.
Implements histograms::Histogram.
|
overridevirtual |
Convert this histogram to a JSON object.
This function will take the contents of the current histogram and put it in the output parameter "json_object".
| [in,out] | json_object | output where the histogram is to be stored. The caller is responsible for allocating/deallocating the JSON object |
Implements histograms::Histogram.
|
overridevirtual |
Returns the histogram type as a readable string.
Implements histograms::Histogram.
|
overrideprotectedvirtual |
Populate this histogram with contents from a JSON object.
| json_object | a JSON object that represents an Singleton histogram |
| context | error context for validation |
Implements histograms::Histogram.
|
inlinestaticconstexprprivate |
String representation of the histogram type SINGLETON.
|
private |
The buckets for this histogram [value, cumulative frequency].