MySQL 9.1.0
Source Code Documentation
|
Represents a bidirectional map between TSID and SIDNO. More...
#include <rpl_gtid.h>
Public Types | |
using | Tsid = mysql::gtid::Tsid |
using | Tag = mysql::gtid::Tag |
using | Tsid_to_sidno_allocator = Map_allocator_type< Tsid, rpl_sidno > |
using | Tsid_to_sidno_umap = malloc_unordered_map< Tsid, rpl_sidno, Tsid::Hash > |
using | Tsid_to_sidno_map = Map_myalloc< Tsid, rpl_sidno > |
using | Tsid_to_sidno_it = Tsid_to_sidno_map::const_iterator |
using | Tsid_ref = std::reference_wrapper< const Tsid > |
using | Sidno_to_tsid_cont = std::vector< Tsid_ref, Malloc_allocator< Tsid_ref > > |
Public Member Functions | |
Tsid_map (Checkable_rwlock *tsid_lock) | |
Create this Tsid_map. More... | |
~Tsid_map () | |
Destroy this Tsid_map. More... | |
enum_return_status | clear () |
Clears this Tsid_map (for RESET REPLICA) More... | |
rpl_sidno | add_tsid (const Tsid &tsid) |
Add the given TSID to this map if it does not already exist. More... | |
rpl_sidno | tsid_to_sidno (const Tsid &tsid) const |
Get the SIDNO for a given TSID. More... | |
const Tsid & | sidno_to_tsid (rpl_sidno sidno, bool need_lock=false) const |
Get the TSID for a given SIDNO. More... | |
const Tsid_to_sidno_map & | get_sorted_sidno () const |
Returns TSID to SID map. More... | |
const rpl_sidno & | get_sidno (const Tsid_to_sidno_it &it) const |
const Tsid & | get_tsid (const Tsid_to_sidno_it &it) const |
rpl_sidno | get_max_sidno () const |
Return the biggest sidno in this Tsid_map. More... | |
Checkable_rwlock * | get_tsid_lock () const |
Return the tsid_lock. More... | |
enum_return_status | copy (Tsid_map *dest) |
Deep copy this Tsid_map to dest. More... | |
Private Member Functions | |
enum_return_status | add_node (rpl_sidno sidno, const Tsid &tsid) |
Create a Node from the given SIDNO and a TSID and add it to _sidno_to_tsid, _tsid_to_sidno, and _sorted. More... | |
Private Attributes | |
Checkable_rwlock * | tsid_lock |
Read-write lock that protects updates to the number of SIDNOs. More... | |
Sidno_to_tsid_cont | _sidno_to_tsid |
Array that maps SIDNO to TSID; the element at index N points to a Node with SIDNO N-1. More... | |
Tsid_to_sidno_umap | _tsid_to_sidno {key_memory_tsid_map_Node} |
Hash that maps TSID to SIDNO. More... | |
Tsid_to_sidno_map | _sorted {Tsid_to_sidno_allocator{key_memory_tsid_map_Node}} |
Data structure that maps numbers in the interval [0, get_max_sidno()-1] to SIDNOs, in order of increasing TSID. More... | |
Represents a bidirectional map between TSID and SIDNO.
SIDNOs are always numbers greater or equal to 1.
This data structure OPTIONALLY knows of a read-write lock that protects the number of SIDNOs. The lock is provided by the invoker of the constructor and it is generally the caller's responsibility to acquire the read lock. If the lock is not NULL, access methods assert that the caller already holds the read (or write) lock. If the lock is not NULL and a method of this class grows the number of SIDNOs, then the method temporarily upgrades this lock to a write lock and then degrades it to a read lock again; there will be a short period when the lock is not held at all.
using Tsid_map::Sidno_to_tsid_cont = std::vector<Tsid_ref, Malloc_allocator<Tsid_ref> > |
using Tsid_map::Tag = mysql::gtid::Tag |
using Tsid_map::Tsid = mysql::gtid::Tsid |
using Tsid_map::Tsid_ref = std::reference_wrapper<const Tsid> |
using Tsid_map::Tsid_to_sidno_it = Tsid_to_sidno_map::const_iterator |
using Tsid_map::Tsid_to_sidno_map = Map_myalloc<Tsid, rpl_sidno> |
Tsid_map::Tsid_map | ( | Checkable_rwlock * | tsid_lock | ) |
Create this Tsid_map.
tsid_lock | Read-write lock that protects updates to the number of SIDNOs. |
Tsid_map::~Tsid_map | ( | ) |
Destroy this Tsid_map.
|
private |
Create a Node from the given SIDNO and a TSID and add it to _sidno_to_tsid, _tsid_to_sidno, and _sorted.
The caller must hold the write lock on tsid_lock before invoking this function.
sidno | The SIDNO to add. |
tsid | The TSID to add. |
Add the given TSID to this map if it does not already exist.
The caller must hold the read lock or write lock on tsid_lock before invoking this function. If the TSID does not exist in this map, it will release the read lock, take a write lock, update the map, release the write lock, and take the read lock again.
tsid | The TSID. |
SIDNO | The SIDNO for the TSID (a new SIDNO if the TSID did not exist, an existing if it did exist). |
negative | Error. This function calls my_error. |
enum_return_status Tsid_map::clear | ( | ) |
Clears this Tsid_map (for RESET REPLICA)
enum_return_status Tsid_map::copy | ( | Tsid_map * | dest | ) |
Deep copy this Tsid_map to dest.
The caller must hold: the read lock on this tsid_lock the write lock on the dest tsid_lock before invoking this function.
[out] | dest | The Tsid_map to which the tsids and sidnos will be copied. |
|
inline |
Return the biggest sidno in this Tsid_map.
The caller must hold the read or write lock on tsid_lock before invoking this function.
|
inline |
|
inline |
Returns TSID to SID map.
The caller must hold the read or write lock on tsid_lock before invoking this function.
|
inline |
|
inline |
Return the tsid_lock.
Get the TSID for a given SIDNO.
Raises an assertion if the SIDNO is not valid.
If need_lock is true, acquires tsid_lock->rdlock; otherwise asserts that it is held already.
sidno | The SIDNO. |
need_lock | If true, and tsid_lock!=NULL, this function will acquire tsid_lock before looking up the sid, and then release it. If false, and tsid_lock!=NULL, this function will assert the tsid_lock is already held. If tsid_lock==NULL, nothing is done w.r.t. locking. |
NULL | The SIDNO does not exist in this map. |
ref | Reference to the TSID. The data is shared with this Tsid_map, so should not be modified. It is safe to read the data even after this Tsid_map is modified, but not if this Tsid_map is destroyed. |
Get the SIDNO for a given TSID.
The caller must hold the read lock on tsid_lock before invoking this function.
tsid | The TSID. |
SIDNO | if the given TSID exists in this map. |
0 | if the given TSID does not exist in this map. |
|
private |
Array that maps SIDNO to TSID; the element at index N points to a Node with SIDNO N-1.
|
private |
Data structure that maps numbers in the interval [0, get_max_sidno()-1] to SIDNOs, in order of increasing TSID.
|
private |
Hash that maps TSID to SIDNO.
|
mutableprivate |
Read-write lock that protects updates to the number of SIDNOs.