MySQL 8.4.2
Source Code Documentation
mysql::gtid::Gno_interval Class Reference

This class represents a range of transaction identifiers. More...

#include <gtidset.h>

Public Member Functions

virtual ~Gno_interval ()=default
 
Gno_intervaloperator= (const Gno_interval &other)
 Copy assignment. More...
 
 Gno_interval (const Gno_interval &other)
 Construct a new Gno_interval object from the other one provided. More...
 
virtual bool operator== (const Gno_interval &other) const
 Compares this interval with another one. More...
 
 Gno_interval (gno_t start, gno_t end)
 Construct a new Gno_interval object. More...
 
virtual bool operator< (const Gno_interval &other) const
 Establishes a total order between two intervals. More...
 
virtual bool intersects (const Gno_interval &other) const
 This checks whether this interval intersects with the other. More...
 
virtual bool contiguous (const Gno_interval &other) const
 Checks if this interval is contiguous with the other one. More...
 
virtual bool intersects_or_contiguous (const Gno_interval &other) const
 Checks if the other interval intersects or is contiguous with this one. More...
 
virtual bool add (const Gno_interval &other)
 Adds the other interval to this one. More...
 
virtual gno_t get_start () const
 Gets the first sequence number in the interval. More...
 
virtual gno_t get_end () const
 Gets the last sequence number in the interval. More...
 
virtual std::size_t count () const
 Number of entries in this interval. More...
 
virtual std::string to_string () const
 Gets a human readable representation of this identifier. More...
 
virtual bool is_valid () const
 Checks whether this interval is valid or not. More...
 

Static Public Attributes

static const std::string SEPARATOR_GNO_START_END {"-"}
 In 'UUID:GNO-GNO', this is the '-'. More...
 

Private Attributes

gno_t m_start {0}
 
gno_t m_next_gno_after_end {0}
 

Detailed Description

This class represents a range of transaction identifiers.

A transaction identifier is composed of two parts, the UUID and the sequence number.

There can be multiple transaction identifiers for a given UUID. When their sequence number are contiguous they can be represented as an interval. This is the class that represents on of those intervals.

Constructor & Destructor Documentation

◆ ~Gno_interval()

virtual mysql::gtid::Gno_interval::~Gno_interval ( )
virtualdefault

◆ Gno_interval() [1/2]

mysql::gtid::Gno_interval::Gno_interval ( const Gno_interval other)

Construct a new Gno_interval object from the other one provided.

Note
This operator does not perform any check about the other interval being valid or not. It is up to the caller to verify that if needed.
Parameters
otherThe object to copy.

◆ Gno_interval() [2/2]

mysql::gtid::Gno_interval::Gno_interval ( gno_t  start,
gno_t  end 
)

Construct a new Gno_interval object.

Parameters
startThe start of the interval (inclusive).
endThe end of the interval (inclusive).

Member Function Documentation

◆ add()

bool mysql::gtid::Gno_interval::add ( const Gno_interval other)
virtual

Adds the other interval to this one.

For this operation to complete successfully, the intervals must intersect or be contiguous. Otherwise, the operation will fail.

Note
This operator does not perform any check about the other interval being valid or not. It is up to the caller to verify that if needed, before calling this member function.
Parameters
otherThe interval to add to this one.
Returns
true if the adding was not successful.
false if the adding was successful.

◆ contiguous()

bool mysql::gtid::Gno_interval::contiguous ( const Gno_interval other) const
virtual

Checks if this interval is contiguous with the other one.

Two intervals are contiguous if they do not intersect but there are no gaps between them. No gaps means that the upper limit of interval A is the value immediately preceding the lower limit of interval B, under numeric natural ordering.

Note
This operator does not perform any check about the other interval being valid or not. It is up to the caller to verify that if needed, before calling this member function.
Parameters
otherthe interval to check against.
Returns
true if the intervals are contiguous.
false otherwise.

◆ count()

std::size_t mysql::gtid::Gno_interval::count ( ) const
virtual

Number of entries in this interval.

Returns
the size of the interval.

◆ get_end()

gno_t mysql::gtid::Gno_interval::get_end ( ) const
virtual

Gets the last sequence number in the interval.

Returns
the last sequence number in the interval.

◆ get_start()

gno_t mysql::gtid::Gno_interval::get_start ( ) const
virtual

Gets the first sequence number in the interval.

Returns
the first sequence number of the interval.

◆ intersects()

bool mysql::gtid::Gno_interval::intersects ( const Gno_interval other) const
virtual

This checks whether this interval intersects with the other.

Note
This operator does not perform any check about the other interval being valid or not. It is up to the caller to verify that if needed, before calling this member function.
Parameters
otherThe other interval to check against this one.
Returns
true if the intervals intersect.
false if it does not intersect.

◆ intersects_or_contiguous()

bool mysql::gtid::Gno_interval::intersects_or_contiguous ( const Gno_interval other) const
virtual

Checks if the other interval intersects or is contiguous with this one.

Parameters
otherThe interval to check against this one.
Returns
true if the other interval intersects or is contiguous with this one.
false otherwise.

◆ is_valid()

bool mysql::gtid::Gno_interval::is_valid ( void  ) const
virtual

Checks whether this interval is valid or not.

An interval is invalid if the start value is smaller than 0 or if the start is larger than the end of the interval.

Returns
true if the interval is valid, false otherwise.

◆ operator<()

bool mysql::gtid::Gno_interval::operator< ( const Gno_interval other) const
virtual

Establishes a total order between two intervals.

Total order is determined using the start and end values of the interval.

An interval A comes before interval B if its start value is smaller than the start value of B.

If B's start value is smaller than A's start value then B comes before A.

If A and B have the same start value, the the end of the intervals are checked and if A has a lower interval end than B, then A is considered to come before B in that case.

Note
This operator does not perform any check about the other interval being valid or not. It is up to the caller to verify that if needed, before calling this member function.
Parameters
otherthe other interval.
Returns
true if this is smaller than the other
false if this is equal or greater than the other.

◆ operator=()

Gno_interval & mysql::gtid::Gno_interval::operator= ( const Gno_interval other)

Copy assignment.

Note
This operator does not perform any check about the other interval being valid or not. It is up to the caller to verify that if needed.
Parameters
otherThe other interval to copy.
Returns
Gno_interval& a reference to the copied interval.

◆ operator==()

bool mysql::gtid::Gno_interval::operator== ( const Gno_interval other) const
virtual

Compares this interval with another one.

Returns true if there is a match.

Note
This operator does not perform any check about the other interval being valid or not. It is up to the caller to verify that if needed, before calling this member function.
Parameters
otherThe other interval to compare this one with.
Returns
true If both intervals match.
false If intervals do not match.

◆ to_string()

std::string mysql::gtid::Gno_interval::to_string ( ) const
virtual

Gets a human readable representation of this identifier.

Returns
A human readable representation of this identifier.

Member Data Documentation

◆ m_next_gno_after_end

gno_t mysql::gtid::Gno_interval::m_next_gno_after_end {0}
private

◆ m_start

gno_t mysql::gtid::Gno_interval::m_start {0}
private

◆ SEPARATOR_GNO_START_END

const std::string mysql::gtid::Gno_interval::SEPARATOR_GNO_START_END {"-"}
inlinestatic

In 'UUID:GNO-GNO', this is the '-'.


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