MySQL 8.0.40
Source Code Documentation
dd::cache::Shared_dictionary_cache Class Reference

#include <shared_dictionary_cache.h>

Classes

struct  Type_selector
 

Public Member Functions

template<typename K , typename T >
bool available (const K &key)
 Check if an element with the given key is available. More...
 
template<typename K , typename T >
bool get (THD *thd, const K &key, Cache_element< T > **element)
 Get an element from the cache, given the key. More...
 
template<typename K , typename T >
bool get_uncached (THD *thd, const K &key, enum_tx_isolation isolation, const T **object) const
 Read an object directly from disk, given the key. More...
 
template<typename T >
void put (const T *object, Cache_element< T > **element)
 Add an object to the shared cache. More...
 
template<typename T >
void release (Cache_element< T > *e)
 Release an element used by a client. More...
 
template<typename T >
void drop (Cache_element< T > *element)
 Delete an element from the cache. More...
 
template<typename K , typename T >
void drop_if_present (const K &key)
 Delete an element corresponding to the key from the cache if exists. More...
 
template<typename T >
void replace (Cache_element< T > *element, const T *object)
 Replace the object and re-create the keys for an element. More...
 
template<typename T >
void dump () const
 Debug dump of a shared cache partition to stderr. More...
 

Static Public Member Functions

static Shared_dictionary_cacheinstance ()
 
static void init ()
 
static void shutdown ()
 
static void reset (bool keep_dd_entities)
 
static bool reset_tables_and_tablespaces (THD *thd)
 

Private Member Functions

Shared_multi_map< Abstract_table > * m_map (Type_selector< Abstract_table >)
 Overloaded functions to use for selecting map instance based on a key type. More...
 
Shared_multi_map< Charset > * m_map (Type_selector< Charset >)
 
Shared_multi_map< Collation > * m_map (Type_selector< Collation >)
 
Shared_multi_map< Column_statistics > * m_map (Type_selector< Column_statistics >)
 
Shared_multi_map< Event > * m_map (Type_selector< Event >)
 
Shared_multi_map< Resource_group > * m_map (Type_selector< Resource_group >)
 
Shared_multi_map< Routine > * m_map (Type_selector< Routine >)
 
Shared_multi_map< Schema > * m_map (Type_selector< Schema >)
 
Shared_multi_map< Spatial_reference_system > * m_map (Type_selector< Spatial_reference_system >)
 
Shared_multi_map< Tablespace > * m_map (Type_selector< Tablespace >)
 
const Shared_multi_map< Abstract_table > * m_map (Type_selector< Abstract_table >) const
 
const Shared_multi_map< Charset > * m_map (Type_selector< Charset >) const
 
const Shared_multi_map< Collation > * m_map (Type_selector< Collation >) const
 
const Shared_multi_map< Column_statistics > * m_map (Type_selector< Column_statistics >) const
 
const Shared_multi_map< Schema > * m_map (Type_selector< Schema >) const
 
const Shared_multi_map< Spatial_reference_system > * m_map (Type_selector< Spatial_reference_system >) const
 
const Shared_multi_map< Tablespace > * m_map (Type_selector< Tablespace >) const
 
const Shared_multi_map< Resource_group > * m_map (Type_selector< Resource_group >) const
 
template<typename T >
Shared_multi_map< T > * m_map ()
 Template function to get a map instance. More...
 
template<typename T >
const Shared_multi_map< T > * m_map () const
 
 Shared_dictionary_cache ()=default
 

Private Attributes

Shared_multi_map< Abstract_tablem_abstract_table_map
 
Shared_multi_map< Charsetm_charset_map
 
Shared_multi_map< Collationm_collation_map
 
Shared_multi_map< Column_statisticsm_column_stat_map
 
Shared_multi_map< Eventm_event_map
 
Shared_multi_map< Resource_groupm_resource_group_map
 
Shared_multi_map< Routinem_routine_map
 
Shared_multi_map< Schemam_schema_map
 
Shared_multi_map< Spatial_reference_systemm_spatial_reference_system_map
 
Shared_multi_map< Tablespacem_tablespace_map
 

Static Private Attributes

static const size_t collation_capacity = 256
 
static const size_t column_statistics_capacity = 32
 
static const size_t charset_capacity = 64
 
static const size_t event_capacity = 256
 
static const size_t spatial_reference_system_capacity = 256
 
static const size_t resource_group_capacity = 32
 Maximum number of DD resource group objects to be kept in cache. More...
 

Constructor & Destructor Documentation

◆ Shared_dictionary_cache()

dd::cache::Shared_dictionary_cache::Shared_dictionary_cache ( )
privatedefault

Member Function Documentation

◆ available()

template<typename K , typename T >
bool dd::cache::Shared_dictionary_cache::available ( const K &  key)
inline

Check if an element with the given key is available.

Parameters
keyKey to check for presence.
Return values
trueThe key exist.
falseThe key does not exist.

◆ drop()

template<typename T >
void dd::cache::Shared_dictionary_cache::drop ( Cache_element< T > *  element)
inline

Delete an element from the cache.

This function will remove the element from the cache and delete the object pointed to. This means that all keys associated with the element will be removed from the maps, and the cache element wrapper will be deleted. The object may not be accessed after calling this function.

Template Parameters
TDictionary object type.
Parameters
elementElement pointer.

◆ drop_if_present()

template<typename K , typename T >
void dd::cache::Shared_dictionary_cache::drop_if_present ( const K &  key)
inline

Delete an element corresponding to the key from the cache if exists.

This function will find the element corresponding to the key if it exists. After that it will remove the element from the cache i.e. all maps, and delete the object pointed to. This means that all keys associated with the element will be removed from the maps, and the cache element wrapper will be deleted.

Template Parameters
KKey type.
TDictionary object type.
Parameters
keyKey to be checked.

◆ dump()

template<typename T >
void dd::cache::Shared_dictionary_cache::dump ( ) const
inline

Debug dump of a shared cache partition to stderr.

Template Parameters
TDictionary object type.

◆ get()

template<typename K , typename T >
bool dd::cache::Shared_dictionary_cache::get ( THD thd,
const K &  key,
Cache_element< T > **  element 
)

Get an element from the cache, given the key.

The operation retrieves an element by one of its keys from the cache (possibly involving a cache miss, which will need the thd to handle the miss) and returns it through the parameter. If there is no element for the given key, NULL is returned. The cache owns the returned element, i.e., the caller must not delete it. After using the element, release() must be called for every element received via get(). The reference counter for the element is incremented if the element is retrieved from the shared cache.

Template Parameters
KKey type.
TDictionary object type.
Parameters
thdThread context.
keyKey to use for looking up the object.
[out]elementElement pointer, if present. NULL if not present.
Return values
falseNo error.
trueError (from handling a cache miss).

◆ get_uncached()

template<typename K , typename T >
bool dd::cache::Shared_dictionary_cache::get_uncached ( THD thd,
const K &  key,
enum_tx_isolation  isolation,
const T **  object 
) const

Read an object directly from disk, given the key.

The operation retrieves an object by one of its keys from the persistent dd tables. The object is returned without being added to the shared cache. The object returned is owned by the caller, who thus becomes responsible of deleting it.

Template Parameters
KKey type.
TDictionary object type.
Parameters
thdThread context.
keyKey to use for looking up the object.
isolationIsolation level to use.
[out]objectObject pointer, if present. NULL if not present.
Return values
falseNo error.
trueError (from reading from the DD tables).

◆ init()

void dd::cache::Shared_dictionary_cache::init ( )
static

◆ instance()

Shared_dictionary_cache * dd::cache::Shared_dictionary_cache::instance ( )
static

◆ m_map() [1/20]

template<typename T >
Shared_multi_map< T > * dd::cache::Shared_dictionary_cache::m_map ( )
inlineprivate

Template function to get a map instance.

To support generic code, the map instances are available through template function instances. This allows looking up the appropriate instance based on the key type. We must use overloading to accomplish this (see above). Const and non-const variants.

Template Parameters
TDictionary object type.
Returns
The shared map handling objects of type T.

◆ m_map() [2/20]

template<typename T >
const Shared_multi_map< T > * dd::cache::Shared_dictionary_cache::m_map ( ) const
inlineprivate

◆ m_map() [3/20]

Shared_multi_map< Abstract_table > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Abstract_table )
inlineprivate

Overloaded functions to use for selecting map instance based on a key type.

Const and non-const variants.

◆ m_map() [4/20]

const Shared_multi_map< Abstract_table > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Abstract_table ) const
inlineprivate

◆ m_map() [5/20]

Shared_multi_map< Charset > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Charset )
inlineprivate

◆ m_map() [6/20]

const Shared_multi_map< Charset > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Charset ) const
inlineprivate

◆ m_map() [7/20]

Shared_multi_map< Collation > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Collation )
inlineprivate

◆ m_map() [8/20]

const Shared_multi_map< Collation > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Collation ) const
inlineprivate

◆ m_map() [9/20]

Shared_multi_map< Column_statistics > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Column_statistics )
inlineprivate

◆ m_map() [10/20]

const Shared_multi_map< Column_statistics > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Column_statistics ) const
inlineprivate

◆ m_map() [11/20]

Shared_multi_map< Event > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Event )
inlineprivate

◆ m_map() [12/20]

Shared_multi_map< Resource_group > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Resource_group )
inlineprivate

◆ m_map() [13/20]

const Shared_multi_map< Resource_group > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Resource_group ) const
inlineprivate

◆ m_map() [14/20]

Shared_multi_map< Routine > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Routine )
inlineprivate

◆ m_map() [15/20]

Shared_multi_map< Schema > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Schema )
inlineprivate

◆ m_map() [16/20]

const Shared_multi_map< Schema > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Schema ) const
inlineprivate

◆ m_map() [17/20]

Shared_multi_map< Spatial_reference_system > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Spatial_reference_system )
inlineprivate

◆ m_map() [18/20]

const Shared_multi_map< Spatial_reference_system > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Spatial_reference_system ) const
inlineprivate

◆ m_map() [19/20]

Shared_multi_map< Tablespace > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Tablespace )
inlineprivate

◆ m_map() [20/20]

const Shared_multi_map< Tablespace > * dd::cache::Shared_dictionary_cache::m_map ( Type_selector< Tablespace ) const
inlineprivate

◆ put()

template<typename T >
template void dd::cache::Shared_dictionary_cache::put< Resource_group > ( const T *  object,
Cache_element< T > **  element 
)

Add an object to the shared cache.

The object may not be present already. The object is added to the cache, the use counter of its element wrapper in incremented, and the element pointer is returned. The user must release the object afterwards. The cache is the owner of the returned element and object.

Template Parameters
TDictionary object type.
Parameters
objectObject pointer to be added. May not be NULL.
elementElement pointer, if present. NULL if not present.

◆ release()

template<typename T >
void dd::cache::Shared_dictionary_cache::release ( Cache_element< T > *  e)
inline

Release an element used by a client.

The element must be present and in use. If the element becomes unused, it is added to the free list, which is then rectified to enforce its capacity constraints.

Template Parameters
TDictionary object type.
Parameters
eElement pointer.

◆ replace()

template<typename T >
void dd::cache::Shared_dictionary_cache::replace ( Cache_element< T > *  element,
const T *  object 
)
inline

Replace the object and re-create the keys for an element.

The operation removes the current keys from the internal maps in the cache, assigns the new object to the element, generates new keys based on the new object, and inserts the new keys into the internal maps in the cache. The old object is deleted.

Template Parameters
TDictionary object type.
Parameters
elementElement pointer.
objectNew object to replace the old one.

◆ reset()

void dd::cache::Shared_dictionary_cache::reset ( bool  keep_dd_entities)
static

◆ reset_tables_and_tablespaces()

bool dd::cache::Shared_dictionary_cache::reset_tables_and_tablespaces ( THD thd)
static

◆ shutdown()

void dd::cache::Shared_dictionary_cache::shutdown ( )
static

Member Data Documentation

◆ charset_capacity

const size_t dd::cache::Shared_dictionary_cache::charset_capacity = 64
staticprivate

◆ collation_capacity

const size_t dd::cache::Shared_dictionary_cache::collation_capacity = 256
staticprivate

◆ column_statistics_capacity

const size_t dd::cache::Shared_dictionary_cache::column_statistics_capacity = 32
staticprivate

◆ event_capacity

const size_t dd::cache::Shared_dictionary_cache::event_capacity = 256
staticprivate

◆ m_abstract_table_map

Shared_multi_map<Abstract_table> dd::cache::Shared_dictionary_cache::m_abstract_table_map
private

◆ m_charset_map

Shared_multi_map<Charset> dd::cache::Shared_dictionary_cache::m_charset_map
private

◆ m_collation_map

Shared_multi_map<Collation> dd::cache::Shared_dictionary_cache::m_collation_map
private

◆ m_column_stat_map

Shared_multi_map<Column_statistics> dd::cache::Shared_dictionary_cache::m_column_stat_map
private

◆ m_event_map

Shared_multi_map<Event> dd::cache::Shared_dictionary_cache::m_event_map
private

◆ m_resource_group_map

Shared_multi_map<Resource_group> dd::cache::Shared_dictionary_cache::m_resource_group_map
private

◆ m_routine_map

Shared_multi_map<Routine> dd::cache::Shared_dictionary_cache::m_routine_map
private

◆ m_schema_map

Shared_multi_map<Schema> dd::cache::Shared_dictionary_cache::m_schema_map
private

◆ m_spatial_reference_system_map

Shared_multi_map<Spatial_reference_system> dd::cache::Shared_dictionary_cache::m_spatial_reference_system_map
private

◆ m_tablespace_map

Shared_multi_map<Tablespace> dd::cache::Shared_dictionary_cache::m_tablespace_map
private

◆ resource_group_capacity

const size_t dd::cache::Shared_dictionary_cache::resource_group_capacity = 32
staticprivate

Maximum number of DD resource group objects to be kept in cache.

We use value of 32 which is a fairly reasonable upper limit of resource group configurations that may be in use.

◆ spatial_reference_system_capacity

const size_t dd::cache::Shared_dictionary_cache::spatial_reference_system_capacity = 256
staticprivate

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