MySQL  8.0.19
Source Code Documentation
histograms::Value_map_base Class Referenceabstract

The abstract base class for all Value_map types. More...

#include <value_map.h>

Public Member Functions

 Value_map_base (const CHARSET_INFO *charset, double sampling_rate, Value_map_type data_type)
virtual ~Value_map_base ()
virtual size_t size () const =0
 Returns the number of [value, count] pairs in the Value_map. More...
template<class T >
bool add_values (const T &value, const ha_rows count)
 Add a value with the given count to this Value_map. More...
void add_null_values (const ha_rows count)
 Increase the number of null values with the given count. More...
ha_rows get_num_null_values () const
virtual Histogrambuild_histogram (MEM_ROOT *mem_root, size_t num_buckets, const std::string &db_name, const std::string &tbl_name, const std::string &col_name) const =0
 Create a Histogram from this Value_map. More...
double get_sampling_rate () const
void set_sampling_rate (double sampling_rate)
 Set the sampling rate that was used to generate this Value_map. More...
const CHARSET_INFOget_character_set () const
Value_map_type get_data_type () const
virtual size_t element_overhead () const =0

Protected Attributes

MEM_ROOT m_mem_root

Private Attributes

double m_sampling_rate
const CHARSET_INFOm_charset
ha_rows m_num_null_values
const Value_map_type m_data_type

Detailed Description

The abstract base class for all Value_map types.

We would ideally like to have only one class for the Value map concept (no inheritance) which would gives us an easier interface. But there are some reasons for why we need to to split the class into a non-templated base class and a templated subclass:

  • We are collecting Value_maps in a collection/vector where they have a different template type. This cannot be achieved unless we have a non-templated base class.
  • When working on a collection of Value_maps, it is more convenient to declare the interface in the base class (Value_map_base) so that we don't need to do a cast to the subclass in order to get hold of the methods we want to use.
  • Value_map_base::add_values and Value_map::add_values looks like the same function, but they are not. Value_map_base::add_values is a small functions that helps us cast the Value_map<T> to the correct type (for instance Value_map<longlong>). Ideally, this function would have been pure virtual, but it's not possible to have virtual member function templates.

Constructor & Destructor Documentation

◆ Value_map_base()

histograms::Value_map_base::Value_map_base ( const CHARSET_INFO charset,
double  sampling_rate,
Value_map_type  data_type 

◆ ~Value_map_base()

virtual histograms::Value_map_base::~Value_map_base ( )

Member Function Documentation

◆ add_null_values()

void histograms::Value_map_base::add_null_values ( const ha_rows  count)

Increase the number of null values with the given count.

countThe number of null values.

◆ add_values()

template<class T >
template bool histograms::Value_map_base::add_values ( const T &  value,
const ha_rows  count 

Add a value with the given count to this Value_map.

If the given value already exists, the count will be added to the existing count.

valueThe value to add.
countCount of the value to add.
false on success, and true in case of errors (OOM).

◆ build_histogram()

virtual Histogram* histograms::Value_map_base::build_histogram ( MEM_ROOT mem_root,
size_t  num_buckets,
const std::string &  db_name,
const std::string &  tbl_name,
const std::string &  col_name 
) const
pure virtual

Create a Histogram from this Value_map.

The resulting histogram will have at most "num_buckets" buckets (might be less), and all of its contents will be allocated on the supplied MEM_ROOT.

mem_rootThe MEM_ROOT to allocate the contents on
num_bucketsMaximum number of buckets to create
db_nameDatabase name
tbl_nameTable name
col_nameColumn name
nullptr on error, or a valid histogram if success.

◆ element_overhead()

virtual size_t histograms::Value_map_base::element_overhead ( ) const
pure virtual
the overhead in bytes for each distinct value stored in the Value_map.

◆ get_character_set()

const CHARSET_INFO* histograms::Value_map_base::get_character_set ( ) const
the character set for the data this Value_map contains

◆ get_data_type()

Value_map_type histograms::Value_map_base::get_data_type ( ) const
the data type that this Value_map contains

◆ get_num_null_values()

ha_rows histograms::Value_map_base::get_num_null_values ( ) const
The number of null values in this Value_map.

◆ get_sampling_rate()

double histograms::Value_map_base::get_sampling_rate ( ) const
The sampling rate that was used to generate this Value_map.

◆ set_sampling_rate()

void histograms::Value_map_base::set_sampling_rate ( double  sampling_rate)

Set the sampling rate that was used to generate this Value_map.

sampling_rateThe sampling rate.

◆ size()

virtual size_t histograms::Value_map_base::size ( ) const
pure virtual

Returns the number of [value, count] pairs in the Value_map.

The number of values in the Value_map.

Member Data Documentation

◆ m_charset

const CHARSET_INFO* histograms::Value_map_base::m_charset

◆ m_data_type

const Value_map_type histograms::Value_map_base::m_data_type

◆ m_mem_root

MEM_ROOT histograms::Value_map_base::m_mem_root

◆ m_num_null_values

ha_rows histograms::Value_map_base::m_num_null_values

◆ m_sampling_rate

double histograms::Value_map_base::m_sampling_rate

The documentation for this class was generated from the following files: