MySQL 9.1.0
Source Code Documentation
Locks_hashtable Struct Reference

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_tfind_in_cell (size_t cell_id, F &&f)
 
template<typename F >
lock_tfind_on_page (page_id_t page_id, F &&f)
 
template<typename F >
lock_tfind_on_block (const buf_block_t *block, F &&f)
 
template<typename F >
lock_tfind_on_record (const struct RecID &rec_id, F &&f)
 
template<typename F >
lock_tfind (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_hashtableoperator= (Locks_hashtable &&)=delete
 
Locks_hashtableoperator= (const Locks_hashtable &)=delete
 

Private Attributes

ut::unique_ptr< hash_table_tht
 
Cells_in_use cells_in_use
 

Detailed Description

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).

Member Typedef Documentation

◆ Cells_in_use

Constructor & Destructor Documentation

◆ Locks_hashtable() [1/3]

Locks_hashtable::Locks_hashtable ( size_t  n_cells)
inline

◆ Locks_hashtable() [2/3]

Locks_hashtable::Locks_hashtable ( Locks_hashtable &&  )
privatedelete

◆ Locks_hashtable() [3/3]

Locks_hashtable::Locks_hashtable ( const Locks_hashtable )
privatedelete

Member Function Documentation

◆ append() [1/2]

bool Locks_hashtable::append ( hash_cell_t cell,
lock_t lock 
)
private

◆ append() [2/2]

void Locks_hashtable::append ( lock_t lock,
uint64_t  hash_value 
)

◆ erase() [1/2]

bool Locks_hashtable::erase ( hash_cell_t cell,
lock_t lock 
)
private

◆ erase() [2/2]

void Locks_hashtable::erase ( lock_t lock,
uint64_t  hash_value 
)

◆ find()

template<typename F >
lock_t * Locks_hashtable::find ( F &&  f)

◆ find_in_cell()

template<typename F >
lock_t * Locks_hashtable::find_in_cell ( size_t  cell_id,
F &&  f 
)

◆ find_on_block()

template<typename F >
lock_t * Locks_hashtable::find_on_block ( const buf_block_t block,
F &&  f 
)

◆ find_on_page()

template<typename F >
lock_t * Locks_hashtable::find_on_page ( page_id_t  page_id,
F &&  f 
)

◆ find_on_record()

template<typename F >
lock_t * Locks_hashtable::find_on_record ( const struct RecID rec_id,
F &&  f 
)

◆ find_set_in_this_shard()

size_t Locks_hashtable::find_set_in_this_shard ( size_t  start_pos)
inline

◆ get_cell_id()

size_t Locks_hashtable::get_cell_id ( uint64_t  hash_value)

◆ get_n_cells()

size_t Locks_hashtable::get_n_cells ( )
inline

◆ move_to_front()

void Locks_hashtable::move_to_front ( lock_t lock,
uint64_t  hash_value 
)

◆ operator=() [1/2]

Locks_hashtable & Locks_hashtable::operator= ( const Locks_hashtable )
privatedelete

◆ operator=() [2/2]

Locks_hashtable & Locks_hashtable::operator= ( Locks_hashtable &&  )
privatedelete

◆ prepend() [1/2]

bool Locks_hashtable::prepend ( hash_cell_t cell,
lock_t lock 
)
private

◆ prepend() [2/2]

void Locks_hashtable::prepend ( lock_t lock,
uint64_t  hash_value 
)

◆ resize()

void Locks_hashtable::resize ( size_t  n_cells)

Member Data Documentation

◆ cells_in_use

Cells_in_use Locks_hashtable::cells_in_use
private

◆ ht

ut::unique_ptr<hash_table_t> Locks_hashtable::ht
private

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