|
1 | 1 | /*****************************************************************************
|
2 | 2 |
|
3 | 3 | Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
|
4 |
| -Copyright (c) 2019, MariaDB Corporation. |
| 4 | +Copyright (c) 2019, 2020, MariaDB Corporation. |
5 | 5 |
|
6 | 6 | This program is free software; you can redistribute it and/or modify it under
|
7 | 7 | the terms of the GNU General Public License as published by the Free Software
|
@@ -135,80 +135,49 @@ this must be equal to srv_page_size */
|
135 | 135 | /* @} */
|
136 | 136 |
|
137 | 137 | /** Page identifier. */
|
138 |
| -class page_id_t { |
| 138 | +class page_id_t |
| 139 | +{ |
139 | 140 | public:
|
140 |
| - |
141 |
| - /** Constructor from (space, page_no). |
142 |
| - @param[in] space tablespace id |
143 |
| - @param[in] page_no page number */ |
144 |
| - page_id_t(ulint space, ulint page_no) |
145 |
| - : m_space(uint32_t(space)), m_page_no(uint32(page_no)) |
146 |
| - { |
147 |
| - ut_ad(space <= 0xFFFFFFFFU); |
148 |
| - ut_ad(page_no <= 0xFFFFFFFFU); |
149 |
| - } |
150 |
| - |
151 |
| - bool operator==(const page_id_t& rhs) const |
152 |
| - { |
153 |
| - return m_space == rhs.m_space && m_page_no == rhs.m_page_no; |
154 |
| - } |
155 |
| - bool operator!=(const page_id_t& rhs) const { return !(*this == rhs); } |
156 |
| - |
157 |
| - bool operator<(const page_id_t& rhs) const |
158 |
| - { |
159 |
| - if (m_space == rhs.m_space) { |
160 |
| - return m_page_no < rhs.m_page_no; |
161 |
| - } |
162 |
| - |
163 |
| - return m_space < rhs.m_space; |
164 |
| - } |
165 |
| - |
166 |
| - /** Retrieve the tablespace id. |
167 |
| - @return tablespace id */ |
168 |
| - uint32_t space() const { return m_space; } |
169 |
| - |
170 |
| - /** Retrieve the page number. |
171 |
| - @return page number */ |
172 |
| - uint32_t page_no() const { return m_page_no; } |
173 |
| - |
174 |
| - /** Retrieve the fold value. |
175 |
| - @return fold value */ |
176 |
| - ulint fold() const { return (m_space << 20) + m_space + m_page_no; } |
177 |
| - |
178 |
| - /** Reset the page number only. |
179 |
| - @param[in] page_no page number */ |
180 |
| - void set_page_no(ulint page_no) |
181 |
| - { |
182 |
| - m_page_no = uint32_t(page_no); |
183 |
| - |
184 |
| - ut_ad(page_no <= 0xFFFFFFFFU); |
185 |
| - } |
186 |
| - |
187 |
| - /** Set the FIL_NULL for the space and page_no */ |
188 |
| - void set_corrupt_id() |
189 |
| - { |
190 |
| - m_space = m_page_no = ULINT32_UNDEFINED; |
191 |
| - } |
| 141 | + /** Constructor from (space, page_no). |
| 142 | + @param[in] space tablespace id |
| 143 | + @param[in] page_no page number */ |
| 144 | + page_id_t(ulint space, ulint page_no) : m_id(uint64_t{space} << 32 | page_no) |
| 145 | + { |
| 146 | + ut_ad(space <= 0xFFFFFFFFU); |
| 147 | + ut_ad(page_no <= 0xFFFFFFFFU); |
| 148 | + } |
| 149 | + |
| 150 | + bool operator==(const page_id_t& rhs) const { return m_id == rhs.m_id; } |
| 151 | + bool operator!=(const page_id_t& rhs) const { return m_id != rhs.m_id; } |
| 152 | + |
| 153 | + bool operator<(const page_id_t& rhs) const { return m_id < rhs.m_id; } |
| 154 | + |
| 155 | + /** Retrieve the tablespace id. |
| 156 | + @return tablespace id */ |
| 157 | + uint32_t space() const { return static_cast<uint32_t>(m_id >> 32); } |
| 158 | + |
| 159 | + /** Retrieve the page number. |
| 160 | + @return page number */ |
| 161 | + uint32_t page_no() const { return static_cast<uint32_t>(m_id); } |
| 162 | + |
| 163 | + /** Retrieve the fold value. |
| 164 | + @return fold value */ |
| 165 | + ulint fold() const { return (space() << 20) + space() + page_no(); } |
| 166 | + |
| 167 | + /** Reset the page number only. |
| 168 | + @param[in] page_no page number */ |
| 169 | + void set_page_no(ulint page_no) |
| 170 | + { |
| 171 | + ut_ad(page_no <= 0xFFFFFFFFU); |
| 172 | + m_id= (m_id & ~uint64_t{0} << 32) | page_no; |
| 173 | + } |
| 174 | + |
| 175 | + /** Set the FIL_NULL for the space and page_no */ |
| 176 | + void set_corrupt_id() { m_id= ~uint64_t{0}; } |
192 | 177 |
|
193 | 178 | private:
|
194 |
| - |
195 |
| - /** Tablespace id. */ |
196 |
| - uint32_t m_space; |
197 |
| - |
198 |
| - /** Page number. */ |
199 |
| - uint32_t m_page_no; |
200 |
| - |
201 |
| - /** Declare the overloaded global operator<< as a friend of this |
202 |
| - class. Refer to the global declaration for further details. Print |
203 |
| - the given page_id_t object. |
204 |
| - @param[in,out] out the output stream |
205 |
| - @param[in] page_id the page_id_t object to be printed |
206 |
| - @return the output stream */ |
207 |
| - friend |
208 |
| - std::ostream& |
209 |
| - operator<<( |
210 |
| - std::ostream& out, |
211 |
| - const page_id_t page_id); |
| 179 | + /** The page identifier */ |
| 180 | + uint64_t m_id; |
212 | 181 | };
|
213 | 182 |
|
214 | 183 | #ifndef UNIV_INNOCHECKSUM
|
|
0 commit comments