MySQL 8.0.40
Source Code Documentation
|
A hashmap used by lock sys, to organize locks by page (block), so that it is easy to maintain a list of all locks related to a given page by append(lock,..), prepend(lock,..), erase(lock,..), move_to_front(lock,...) while also providing ability to iterate over all locks related for a given page in that order. More...
#include <lock0lock.h>
Public Types | |
using | Cells_in_use = ut::Sharded_bitset< locksys::Latches::SHARDS_COUNT > |
Public Member Functions | |
Locks_hashtable (size_t n_cells) | |
void | append (lock_t *lock, uint64_t hash_value) |
void | prepend (lock_t *lock, uint64_t hash_value) |
void | erase (lock_t *lock, uint64_t hash_value) |
void | move_to_front (lock_t *lock, uint64_t hash_value) |
void | resize (size_t n_cells) |
template<typename F > | |
lock_t * | find_in_cell (size_t cell_id, F &&f) |
template<typename F > | |
lock_t * | find_on_page (page_id_t page_id, F &&f) |
template<typename F > | |
lock_t * | find_on_block (const buf_block_t *block, F &&f) |
template<typename F > | |
lock_t * | find_on_record (const struct RecID &rec_id, F &&f) |
template<typename F > | |
lock_t * | find (F &&f) |
size_t | get_n_cells () |
size_t | find_set_in_this_shard (size_t start_pos) |
size_t | get_cell_id (uint64_t hash_value) |
Private Member Functions | |
bool | append (hash_cell_t *cell, lock_t *lock) |
bool | prepend (hash_cell_t *cell, lock_t *lock) |
bool | erase (hash_cell_t *cell, lock_t *lock) |
Locks_hashtable (Locks_hashtable &&)=delete | |
Locks_hashtable (const Locks_hashtable &)=delete | |
Locks_hashtable & | operator= (Locks_hashtable &&)=delete |
Locks_hashtable & | operator= (const Locks_hashtable &)=delete |
Private Attributes | |
ut::unique_ptr< hash_table_t > | ht |
Cells_in_use | cells_in_use |
A hashmap used by lock sys, to organize locks by page (block), so that it is easy to maintain a list of all locks related to a given page by append(lock,..), prepend(lock,..), erase(lock,..), move_to_front(lock,...) while also providing ability to iterate over all locks related for a given page in that order.
The hash has a configurable number of cells, and handles conflicts by using a singly linked list for each cell - locks related to same page are guaranteed to hash to the same cell. This detail is exposed because, for performance reasons you might want to resize(n) it, or inspect all locks from a given cell with find_in_cell(cell_id, visitor), or find a next non-empty cell with find_set_in_this_shard(..), or cell to which a given hash_value is mapped with get_cell_id(hash_value).
|
inline |
|
privatedelete |
|
privatedelete |
|
private |
void Locks_hashtable::append | ( | lock_t * | lock, |
uint64_t | hash_value | ||
) |
|
private |
void Locks_hashtable::erase | ( | lock_t * | lock, |
uint64_t | hash_value | ||
) |
lock_t * Locks_hashtable::find | ( | F && | f | ) |
lock_t * Locks_hashtable::find_in_cell | ( | size_t | cell_id, |
F && | f | ||
) |
lock_t * Locks_hashtable::find_on_block | ( | const buf_block_t * | block, |
F && | f | ||
) |
lock_t * Locks_hashtable::find_on_record | ( | const struct RecID & | rec_id, |
F && | f | ||
) |
|
inline |
size_t Locks_hashtable::get_cell_id | ( | uint64_t | hash_value | ) |
|
inline |
void Locks_hashtable::move_to_front | ( | lock_t * | lock, |
uint64_t | hash_value | ||
) |
|
privatedelete |
|
privatedelete |
|
private |
void Locks_hashtable::prepend | ( | lock_t * | lock, |
uint64_t | hash_value | ||
) |
void Locks_hashtable::resize | ( | size_t | n_cells | ) |
|
private |
|
private |