MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sid_map Class Reference

#include <rpl_gtid.h>

Classes

struct  Node
 Node pointed to by both the hash and the array.

Public Member Functions

 Sid_map (Checkable_rwlock *sid_lock)
 ~Sid_map ()
 Destroy this Sid_map.
rpl_sidno add_sid (const rpl_sid &sid)
rpl_sidno sid_to_sidno (const rpl_sid &sid) const
const rpl_sidsidno_to_sid (rpl_sidno sidno) const
rpl_sidno get_sorted_sidno (rpl_sidno n) const
rpl_sidno get_max_sidno () const

Detailed Description

Represents a bidirectional map between SID 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.

Definition at line 467 of file rpl_gtid.h.

Constructor & Destructor Documentation

Sid_map::Sid_map ( Checkable_rwlock sid_lock)

Create this Sid_map.

Parameters
sid_lockRead-write lock that protects updates to the number of SIDNOs.

Definition at line 24 of file rpl_gtid_sid_map.cc.

Member Function Documentation

rpl_sidno Sid_map::add_sid ( const rpl_sid sid)

Add the given SID to this map if it does not already exist.

The caller must hold the read lock or write lock on sid_lock before invoking this function. If the SID 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.

Parameters
sidThe SID.
Return values
SIDNOThe SIDNO for the SID (a new SIDNO if the SID did not exist, an existing if it did exist).
negativeError. This function calls my_error.

Definition at line 68 of file rpl_gtid_sid_map.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

rpl_sidno Sid_map::get_max_sidno ( ) const
inline

Return the biggest sidno in this Sid_map.

The caller must hold the read or write lock on sid_lock before invoking this function.

Definition at line 562 of file rpl_gtid.h.

Here is the call graph for this function:

Here is the caller graph for this function:

rpl_sidno Sid_map::get_sorted_sidno ( rpl_sidno  n) const
inline

Return the n'th smallest sidno, in the order of the SID's UUID.

The caller must hold the read or write lock on sid_lock before invoking this function.

Parameters
nA number in the interval [0, get_max_sidno()-1], inclusively.

Definition at line 549 of file rpl_gtid.h.

Here is the call graph for this function:

Here is the caller graph for this function:

rpl_sidno Sid_map::sid_to_sidno ( const rpl_sid sid) const
inline

Get the SIDNO for a given SID

The caller must hold the read lock on sid_lock before invoking this function.

Parameters
sidThe SID.
Return values
SIDNOif the given SID exists in this map.
0if the given SID does not exist in this map.

Definition at line 511 of file rpl_gtid.h.

Here is the call graph for this function:

Here is the caller graph for this function:

const rpl_sid& Sid_map::sidno_to_sid ( rpl_sidno  sidno) const
inline

Get the SID for a given SIDNO.

An assertion is raised if the caller does not hold a lock on sid_lock, or if the SIDNO is not valid.

Parameters
sidnoThe SIDNO.
Return values
NULLThe SIDNO does not exist in this map.
pointerPointer to the SID. The data is shared with this Sid_map, so should not be modified. It is safe to read the data even after this Sid_map is modified, but not if this Sid_map is destroyed.

Definition at line 534 of file rpl_gtid.h.

Here is the call graph for this function:

Here is the caller graph for this function:


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