24#ifndef DD_CACHE__SHARED_MULTI_MAP_INCLUDED
25#define DD_CACHE__SHARED_MULTI_MAP_INCLUDED
61template <
typename K,
typename E>
68#ifdef HAVE_PSI_INTERFACE
126 typedef std::vector<const T *, Malloc_allocator<const T *>>
132 typedef std::vector<const Cache_element<T> *,
163 for (
typename Object_list_type::const_iterator it =
169 for (
typename Element_list_type::const_iterator it =
186 std::vector<Cache_element<T> *>
205 template <
typename K>
210 template <
typename K>
230 template <
typename K>
256 return this->m_map<const T *>()->size() >
m_capacity;
345 template <
typename K>
349 m_map<K>()->get(
key, &e);
350 return (e !=
nullptr);
378 template <typename K>
424 template <typename K>
469 template <typename K>
491 fprintf(stderr,
" --------------------------------\n");
492 fprintf(stderr,
" Shared multi map for '%s'\n",
493 T::DD_table::instance().
name().c_str());
495 fprintf(stderr,
" Free list:\n");
497 fprintf(stderr,
" --------------------------------\n");
Malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: malloc_allocator.h:63
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Implementation of a dictionary client.
Definition: cache_element.h:69
Implementation of a map between a key type and an element type.
Definition: element_map.h:72
Template for management of a free list based on a std::vector.
Definition: free_list.h:53
Implementation of a set of maps for a given object type.
Definition: multi_map_base.h:64
void dump() const
Debug dump of the multi map base to stderr.
Definition: multi_map_base.h:181
Definition: shared_multi_map.h:123
Autolocker(Shared_multi_map< T > *map)
Definition: shared_multi_map.h:141
Object_list_type m_objects_to_delete
Definition: shared_multi_map.h:128
~Autolocker()
Definition: shared_multi_map.h:160
std::vector< const T *, Malloc_allocator< const T * > > Object_list_type
Definition: shared_multi_map.h:127
Shared_multi_map< T > * m_map
Definition: shared_multi_map.h:137
Element_list_type m_elements_to_delete
Definition: shared_multi_map.h:135
void auto_delete(const Cache_element< T > *element)
Definition: shared_multi_map.h:154
std::vector< const Cache_element< T > *, Malloc_allocator< const Cache_element< T > * > > Element_list_type
Definition: shared_multi_map.h:134
void auto_delete(const T *object)
Definition: shared_multi_map.h:151
Implementation of a shared set of maps for a given object type.
Definition: shared_multi_map.h:118
bool map_capacity_exceeded() const
Check if the current map capacity is exceeded.
Definition: shared_multi_map.h:254
std::vector< Cache_element< T > * > m_element_pool
Definition: shared_multi_map.h:187
bool get(const K &key, Cache_element< T > **element)
Get a wrapper element from the map handling the given key type.
Definition: shared_multi_map.cc:258
size_t m_capacity
Definition: shared_multi_map.h:188
static const size_t initial_capacity
Definition: shared_multi_map.h:120
mysql_mutex_t m_lock
We need a mutex to lock this instance for thread safety, as well as a condition variable for synchron...
Definition: shared_multi_map.h:182
void rectify_free_list(Autolocker *lock)
Helper function to evict unused elements from the free list until the cache capacity is not exceeded.
Definition: shared_multi_map.cc:118
void remove(Cache_element< T > *element, Autolocker *lock)
Remove an element from the map.
Definition: shared_multi_map.cc:75
bool available(const K &key)
Check if an element with the given key is available.
Definition: shared_multi_map.h:346
bool reset(THD *thd)
Reset the shared map.
Definition: shared_multi_map.cc:214
~Shared_multi_map()
Destroy the mutex and condition variable.
Definition: shared_multi_map.h:308
void replace(Cache_element< T > *element, const T *object)
Replace the object and re-generate the keys for an element.
Definition: shared_multi_map.cc:451
Free_list< Cache_element< T > > m_free_list
Definition: shared_multi_map.h:185
void shutdown()
Shutdown the shared map.
Definition: shared_multi_map.cc:148
Cache_element< T > * use_if_present(const K &key)
Template function to find an element and mark it as used.
Definition: shared_multi_map.cc:55
void drop_if_present(const K &key)
Delete an object corresponding to the key from the map if exists.
Definition: shared_multi_map.cc:439
void set_capacity(size_t capacity)
Set capacity of the shared map.
Definition: shared_multi_map.h:335
void drop(Cache_element< T > *element)
Delete an element from the map.
Definition: shared_multi_map.cc:431
void release(Cache_element< T > *element)
Release one element.
Definition: shared_multi_map.cc:398
void evict_all_unused(Autolocker *lock)
Helper function to evict all unused elements from the free list and the cache.
Definition: shared_multi_map.cc:134
Shared_multi_map()
Initialize the mutex and condition variable.
Definition: shared_multi_map.h:299
void dump() const
Debug dump of the shared multi map to stderr.
Definition: shared_multi_map.h:489
mysql_cond_t m_miss_handled
Definition: shared_multi_map.h:183
void put(const K *key, const T *object, Cache_element< T > **element)
Put a new object and element wrapper into the map.
Definition: shared_multi_map.cc:287
bool pool_capacity_exceeded() const
Check if the pool capacity is exceeded.
Definition: shared_multi_map.h:270
const Element_map< K, Cache_element< T > > * m_map() const
Definition: shared_multi_map.h:211
Element_map< K, Cache_element< T > > * m_map()
Template helper function getting the element map.
Definition: shared_multi_map.h:206
#define mysql_cond_destroy(C)
Definition: mysql_cond.h:45
#define mysql_cond_init(K, C)
Definition: mysql_cond.h:42
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:50
#define mysql_mutex_destroy(M)
Definition: mysql_mutex.h:46
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:57
#define mysql_mutex_init(K, M, A)
Definition: mysql_mutex.h:41
unsigned int PSI_cond_key
Instrumented cond key.
Definition: psi_cond_bits.h:44
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:52
#define mysql_mutex_assert_owner(M)
Wrapper, to use safe_mutex_assert_owner with instrumented mutexes.
Definition: mysql_mutex.h:112
Instrumentation helpers for mysys threads.
Header for compiler-dependent features.
#define MY_COMPILER_DIAGNOSTIC_PUSH()
save the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:277
#define MY_COMPILER_DIAGNOSTIC_POP()
restore the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:278
#define MY_COMPILER_CLANG_WORKAROUND_TPARAM_DOCBUG()
ignore -Wdocumentation compiler warnings for @tparam.
Definition: my_compiler.h:300
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
Instrumentation helpers for conditions.
ABI for instrumented mutexes.
ulong max_connections
Definition: mysqld.cc:1389
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2894
static std::mutex lock
Definition: net_ns.cc:56
Instrumentation helpers for conditions.
Instrumentation helpers for mutexes.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
PSI_memory_key key_memory_DD_cache_infrastructure
Definition: psi_memory_key.cc:37
Instrumentation helpers for mutexes.
required string key
Definition: replication_asynchronous_connection_failover.proto:60
PSI_mutex_key key_object_cache_mutex
Definition: mysqld.cc:13771
PSI_cond_key key_object_loading_cond
Definition: mysqld.cc:13772
case opt name
Definition: sslopt-case.h:29
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
MySQL mutex implementation.
#define MY_MUTEX_INIT_FAST
Definition: thr_mutex.h:68