MySQL 8.0.40
Source Code Documentation
histograms::Value_map< T > Class Template Reference

Value_map class. More...

#include <value_map.h>

Inheritance diagram for histograms::Value_map< T >:
[legend]

Public Member Functions

 Value_map (const CHARSET_INFO *charset, Value_map_type data_type)
 
size_t size () const override
 Returns the number of [value, count] pairs in the Value_map. More...
 
value_map_type::const_iterator begin () const
 
value_map_type::const_iterator end () const
 
bool add_values (const T &value, const ha_rows count)
 
bool insert (typename value_map_type::const_iterator begin, typename value_map_type::const_iterator end)
 Insert a range of values into the Value_map. More...
 
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 override
 Create a Histogram from this Value_map. More...
 
size_t element_overhead () const override
 
bool add_values (const String &value, const ha_rows count)
 
- Public Member Functions inherited from histograms::Value_map_base
 Value_map_base (const CHARSET_INFO *charset, Value_map_type data_type)
 
virtual ~Value_map_base ()=default
 
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
 
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
 

Private Types

using value_map_type = std::map< T, ha_rows, Histogram_comparator, Mem_root_allocator< std::pair< const T, ha_rows > > >
 

Private Attributes

value_map_type m_value_map
 

Additional Inherited Members

- Protected Attributes inherited from histograms::Value_map_base
MEM_ROOT m_mem_root
 

Detailed Description

template<class T>
class histograms::Value_map< T >

Value_map class.

This class works as a map. It is a collection of [key, count], where "count" is the number of occurrences of "key". The class abstracts away things like duplicate checking and the underlying container.

Member Typedef Documentation

◆ value_map_type

template<class T >
using histograms::Value_map< T >::value_map_type = std::map<T, ha_rows, Histogram_comparator, Mem_root_allocator<std::pair<const T, ha_rows> >>
private

Constructor & Destructor Documentation

◆ Value_map()

template<class T >
histograms::Value_map< T >::Value_map ( const CHARSET_INFO charset,
Value_map_type  data_type 
)
inline

Member Function Documentation

◆ add_values() [1/2]

bool histograms::Value_map< String >::add_values ( const String value,
const ha_rows  count 
)

◆ add_values() [2/2]

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

◆ begin()

template<class T >
value_map_type::const_iterator histograms::Value_map< T >::begin ( void  ) const
inline

◆ build_histogram()

template<class T >
Histogram * histograms::Value_map< T >::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
overridevirtual

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.

Parameters
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
Returns
nullptr on error, or a valid histogram if success.

Implements histograms::Value_map_base.

◆ element_overhead()

template<class T >
size_t histograms::Value_map< T >::element_overhead ( ) const
inlineoverridevirtual
Returns
the overhead in bytes for each distinct value stored in the Value_map. The value 32 is obtained from both GCC 8.2 and Clang 8.0 (same as sizeof(value_map_type::node_type) in C++17).

Implements histograms::Value_map_base.

◆ end()

template<class T >
value_map_type::const_iterator histograms::Value_map< T >::end ( void  ) const
inline

◆ insert()

template<class T >
bool histograms::Value_map< T >::insert ( typename value_map_type::const_iterator  begin,
typename value_map_type::const_iterator  end 
)

Insert a range of values into the Value_map.

Values in the range (begin, end] must be sorted according to Histogram_comparator. Note that this function is currently only used in unit testing.

Note
The value map must be empty before calling this function.
Parameters
beginIterator that points to the beginning of the range.
endIterator that points to the end of the range.
Returns
false on success, true on error (OOM or similar).

◆ size()

template<class T >
size_t histograms::Value_map< T >::size ( ) const
inlineoverridevirtual

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

Returns
The number of values in the Value_map.

Implements histograms::Value_map_base.

Member Data Documentation

◆ m_value_map

template<class T >
value_map_type histograms::Value_map< T >::m_value_map
private

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