MySQL 8.4.2
Source Code Documentation
dd::info_schema::Tablespace_statistics Class Reference

The class hold dynamic table statistics for a table. More...

#include <tablespace_stats.h>

Public Member Functions

 Tablespace_statistics ()
 
bool is_stat_cached (const String &tablespace_name, const String &file_name)
 Check if the stats are cached for given tablespace_name and file_name. More...
 
void cache_stats (const String &tablespace_name, const String &file_name, ha_tablespace_statistics &stats)
 Store the statistics form the given handler. More...
 
bool read_stat (THD *thd, const String &tablespace_name_ptr, const String &file_name_ptr, const String &engine_name_ptr, const char *ts_se_private_data)
 Read dynamic tablespace statistics from SE API OR by reading cached statistics from Query_block. More...
 
void invalidate_cache (void)
 
void mark_as_error_found (const String &tablespace_name, const String &file_name)
 Mark that error was found for the given key. More...
 
void get_stat (enum_tablespace_stats_type stype, ulonglong *result)
 Return statistics of the a given type. More...
 
void get_stat (enum_tablespace_stats_type stype, dd::String_type *result)
 
bool is_valid () const
 Predicate for determinig if cache is valid. More...
 

Public Attributes

ha_tablespace_statistics m_stats
 

Private Member Functions

void set_stat_cached (const String &tablespace_name, const String &file_name)
 Mark the cache as valid for a given table. More...
 
String_type form_key (const String &tablespace_name, const String &file_name)
 Build a key representing the table for which stats are cached. More...
 
bool check_error_for_key (const String &tablespace_name, const String &file_name)
 Check if we have seen a error. More...
 
bool read_stat_from_SE (THD *thd, const String &tablespace_name_ptr, const String &file_name_ptr, const String &engine_name_ptr, const char *ts_se_private_data)
 Read dynamic tablespace statistics from SE API. More...
 

Private Attributes

String_type m_key
 
bool m_found_error
 

Detailed Description

The class hold dynamic table statistics for a table.

This cache is used by internal UDF's defined for the purpose of INFORMATION_SCHEMA queries which retrieve dynamic table statistics. The class caches statistics for just one table.

Overall aim of introducing this cache is to avoid making multiple calls to same SE API to retrieve the statistics.

Constructor & Destructor Documentation

◆ Tablespace_statistics()

dd::info_schema::Tablespace_statistics::Tablespace_statistics ( )
inline

Member Function Documentation

◆ cache_stats()

void dd::info_schema::Tablespace_statistics::cache_stats ( const String tablespace_name,
const String file_name,
ha_tablespace_statistics stats 
)
inline

Store the statistics form the given handler.

Parameters
tablespace_name- Tablespace name.
file_name- File name.
stats- ha_tablespace_statistics.

◆ check_error_for_key()

bool dd::info_schema::Tablespace_statistics::check_error_for_key ( const String tablespace_name,
const String file_name 
)
inlineprivate

Check if we have seen a error.

Parameters
tablespace_name- Tablespace name.
file_name- File name.
Returns
true if there is error reported. false if not.

◆ form_key()

String_type dd::info_schema::Tablespace_statistics::form_key ( const String tablespace_name,
const String file_name 
)
inlineprivate

Build a key representing the table for which stats are cached.

Parameters
tablespace_name- Tablespace name.
file_name- File name.
Returns
String_type representing the key.

◆ get_stat() [1/2]

void dd::info_schema::Tablespace_statistics::get_stat ( enum_tablespace_stats_type  stype,
dd::String_type result 
)

◆ get_stat() [2/2]

void dd::info_schema::Tablespace_statistics::get_stat ( enum_tablespace_stats_type  stype,
ulonglong result 
)

Return statistics of the a given type.

Parameters
stypeType of statistics requested.
[out]resultValue for stype.

◆ invalidate_cache()

void dd::info_schema::Tablespace_statistics::invalidate_cache ( void  )
inline

◆ is_stat_cached()

bool dd::info_schema::Tablespace_statistics::is_stat_cached ( const String tablespace_name,
const String file_name 
)
inline

Check if the stats are cached for given tablespace_name and file_name.

Parameters
tablespace_name- Tablespace name.
file_name- File name.
Returns
true if stats are cached, else false.

◆ is_valid()

bool dd::info_schema::Tablespace_statistics::is_valid ( void  ) const
inline

Predicate for determinig if cache is valid.

◆ mark_as_error_found()

void dd::info_schema::Tablespace_statistics::mark_as_error_found ( const String tablespace_name,
const String file_name 
)
inline

Mark that error was found for the given key.

The combination of tablespace and file name forms the key.

Parameters
tablespace_name- Tablespace name.
file_name- File name.

◆ read_stat()

bool dd::info_schema::Tablespace_statistics::read_stat ( THD thd,
const String tablespace_name_ptr,
const String file_name_ptr,
const String engine_name_ptr,
const char *  ts_se_private_data 
)

Read dynamic tablespace statistics from SE API OR by reading cached statistics from Query_block.

Parameters
thd- Current thread.
tablespace_name_ptr- Tablespace name of which we need stats.
file_name_ptr- File name.
engine_name_ptr- Engine name.
ts_se_private_data- Tablespace se private data.
Returns
true if statistics were not fetched from SE, otherwise false.

◆ read_stat_from_SE()

bool dd::info_schema::Tablespace_statistics::read_stat_from_SE ( THD thd,
const String tablespace_name_ptr,
const String file_name_ptr,
const String engine_name_ptr,
const char *  ts_se_private_data 
)
private

Read dynamic tablespace statistics from SE API.

Parameters
thd- Current thread.
tablespace_name_ptr- Tablespace name of which we need stats.
file_name_ptr- File name.
engine_name_ptr- Engine name.
ts_se_private_data- Tablespace se private data.
Returns
true if statistics were not fetched from SE, otherwise false.

◆ set_stat_cached()

void dd::info_schema::Tablespace_statistics::set_stat_cached ( const String tablespace_name,
const String file_name 
)
inlineprivate

Mark the cache as valid for a given table.

This creates a key for the cache element. We store just a single table statistics in this cache.

Parameters
tablespace_name- Tablespace name.
file_name- File name.

Member Data Documentation

◆ m_found_error

bool dd::info_schema::Tablespace_statistics::m_found_error
private

◆ m_key

String_type dd::info_schema::Tablespace_statistics::m_key
private

◆ m_stats

ha_tablespace_statistics dd::info_schema::Tablespace_statistics::m_stats

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