Commit 9d142a89 authored by Marko Mäkelä's avatar Marko Mäkelä

Define page_id_t in buf0types.h

parent 80a142f1
...@@ -215,77 +215,6 @@ struct buf_pools_list_size_t { ...@@ -215,77 +215,6 @@ struct buf_pools_list_size_t {
}; };
#endif /* !UNIV_INNOCHECKSUM */ #endif /* !UNIV_INNOCHECKSUM */
/** Page identifier. */
class page_id_t {
public:
/** Constructor from (space, page_no).
@param[in] space tablespace id
@param[in] page_no page number */
page_id_t(ulint space, ulint page_no)
: m_space(uint32_t(space)), m_page_no(uint32(page_no))
{
ut_ad(space <= 0xFFFFFFFFU);
ut_ad(page_no <= 0xFFFFFFFFU);
}
bool operator==(const page_id_t& rhs) const
{
return m_space == rhs.m_space && m_page_no == rhs.m_page_no;
}
bool operator!=(const page_id_t& rhs) const { return !(*this == rhs); }
bool operator<(const page_id_t& rhs) const
{
if (m_space == rhs.m_space) {
return m_page_no < rhs.m_page_no;
}
return m_space < rhs.m_space;
}
/** Retrieve the tablespace id.
@return tablespace id */
uint32_t space() const { return m_space; }
/** Retrieve the page number.
@return page number */
uint32_t page_no() const { return m_page_no; }
/** Retrieve the fold value.
@return fold value */
ulint fold() const { return (m_space << 20) + m_space + m_page_no; }
/** Reset the page number only.
@param[in] page_no page number */
inline void set_page_no(ulint page_no)
{
m_page_no = uint32_t(page_no);
ut_ad(page_no <= 0xFFFFFFFFU);
}
private:
/** Tablespace id. */
uint32_t m_space;
/** Page number. */
uint32_t m_page_no;
/** Declare the overloaded global operator<< as a friend of this
class. Refer to the global declaration for further details. Print
the given page_id_t object.
@param[in,out] out the output stream
@param[in] page_id the page_id_t object to be printed
@return the output stream */
friend
std::ostream&
operator<<(
std::ostream& out,
const page_id_t page_id);
};
/** Print the given page_id_t object. /** Print the given page_id_t object.
@param[in,out] out the output stream @param[in,out] out the output stream
@param[in] page_id the page_id_t object to be printed @param[in] page_id the page_id_t object to be printed
......
...@@ -125,6 +125,77 @@ this must be equal to UNIV_PAGE_SIZE */ ...@@ -125,6 +125,77 @@ this must be equal to UNIV_PAGE_SIZE */
#define BUF_BUDDY_HIGH (BUF_BUDDY_LOW << BUF_BUDDY_SIZES) #define BUF_BUDDY_HIGH (BUF_BUDDY_LOW << BUF_BUDDY_SIZES)
/* @} */ /* @} */
/** Page identifier. */
class page_id_t {
public:
/** Constructor from (space, page_no).
@param[in] space tablespace id
@param[in] page_no page number */
page_id_t(ulint space, ulint page_no)
: m_space(uint32_t(space)), m_page_no(uint32(page_no))
{
ut_ad(space <= 0xFFFFFFFFU);
ut_ad(page_no <= 0xFFFFFFFFU);
}
bool operator==(const page_id_t& rhs) const
{
return m_space == rhs.m_space && m_page_no == rhs.m_page_no;
}
bool operator!=(const page_id_t& rhs) const { return !(*this == rhs); }
bool operator<(const page_id_t& rhs) const
{
if (m_space == rhs.m_space) {
return m_page_no < rhs.m_page_no;
}
return m_space < rhs.m_space;
}
/** Retrieve the tablespace id.
@return tablespace id */
uint32_t space() const { return m_space; }
/** Retrieve the page number.
@return page number */
uint32_t page_no() const { return m_page_no; }
/** Retrieve the fold value.
@return fold value */
ulint fold() const { return (m_space << 20) + m_space + m_page_no; }
/** Reset the page number only.
@param[in] page_no page number */
void set_page_no(ulint page_no)
{
m_page_no = uint32_t(page_no);
ut_ad(page_no <= 0xFFFFFFFFU);
}
private:
/** Tablespace id. */
uint32_t m_space;
/** Page number. */
uint32_t m_page_no;
/** Declare the overloaded global operator<< as a friend of this
class. Refer to the global declaration for further details. Print
the given page_id_t object.
@param[in,out] out the output stream
@param[in] page_id the page_id_t object to be printed
@return the output stream */
friend
std::ostream&
operator<<(
std::ostream& out,
const page_id_t page_id);
};
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
#include "ut0mutex.h" #include "ut0mutex.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment