MySQL 8.4.3
Source Code Documentation
|
The Table_histograms_collection manages a collection of reference-counted snapshots of histogram statistics (Table_histograms objects) for a table. More...
#include <table_histograms.h>
Public Member Functions | |
Table_histograms_collection () | |
Table_histograms_collection (Table_histograms_collection &&)=delete | |
Table_histograms_collection & | operator= (Table_histograms_collection &&)=delete |
Table_histograms_collection (const Table_histograms_collection &)=delete | |
Table_histograms_collection & | operator= (const Table_histograms_collection &)=delete |
~Table_histograms_collection () | |
const Table_histograms * | acquire () |
Acquire a pointer to the most recently inserted Table_histograms object. More... | |
void | release (const Table_histograms *histograms) |
Release a previously acquired Table_histograms object, decreasing its reference count. More... | |
bool | insert (Table_histograms *histograms) |
Attempt to insert the supplied Table_histograms object into the collection. More... | |
int | total_reference_count () const |
Count the total number of TABLE objects referencing Table_histograms objects in the collection. More... | |
size_t | size () const |
Counts the number of Table_histograms objects in the collection. More... | |
Private Member Functions | |
void | free_table_histograms (size_t idx) |
Frees a Table_histograms object from the collection and sets its pointer to nullptr. More... | |
Private Attributes | |
std::array< Table_histograms *, kMaxNumberOfTableHistogramsInCollection > | m_table_histograms |
size_t | m_current_index {0} |
The Table_histograms_collection manages a collection of reference-counted snapshots of histogram statistics (Table_histograms objects) for a table.
It is intended to live on the TABLE_SHARE and provide TABLE objects with reference-counted access to Table_histogram objects through the acquire() and release() methods. The motivation for this class is to decouple the lifetime of histogram statistics from the lifetime of the TABLE_SHARE, so that we avoid having to invalidate the TABLE_SHARE when updating/dropping histograms.
Multiple threads can be opening/closing tables concurrently. Member functions on the Table_histograms_collection should be protected by holding LOCK_open.
When the TABLE_SHARE is initialized and whenever the histograms associated with a table are updated, we create a new Table_histograms object, insert it into the collection, and mark it current.
Table_histograms_collection::Table_histograms_collection | ( | ) |
|
delete |
|
delete |
Table_histograms_collection::~Table_histograms_collection | ( | ) |
const Table_histograms * Table_histograms_collection::acquire | ( | ) |
Acquire a pointer to the most recently inserted Table_histograms object.
Increments the reference counter on the returned Table_histograms object.
|
inlineprivate |
Frees a Table_histograms object from the collection and sets its pointer to nullptr.
idx | Index of the Table_histograms object to free. |
bool Table_histograms_collection::insert | ( | Table_histograms * | histograms | ) |
Attempt to insert the supplied Table_histograms object into the collection.
The insertion will fail if the collection is full. If the insertion succeeds we mark the object as current and take ownership. The previous current object is deleted if it has a reference count of zero
histograms | Pointer to the Table_histograms object to be inserted. |
|
delete |
|
delete |
void Table_histograms_collection::release | ( | const Table_histograms * | histograms | ) |
Release a previously acquired Table_histograms object, decreasing its reference count.
If the reference count of a non-current Table_histograms object reaches zero we delete it. This frees up memory and makes room for a new Table_histograms object in the collection.
histograms | Pointer to a Table_histograms object to be released. |
size_t Table_histograms_collection::size | ( | ) | const |
Counts the number of Table_histograms objects in the collection.
Primarily used for testing.
int Table_histograms_collection::total_reference_count | ( | ) | const |
Count the total number of TABLE objects referencing Table_histograms objects in the collection.
Primarily used for testing.
|
private |
|
private |