MySQL 9.1.0
Source Code Documentation
Btree_multi::Page_extent Struct Reference

Allocate, use, manage and flush one extent pages (FSP_EXTENT_SIZE). More...

#include <btr0mtib.h>

Public Types

using Page_range_t = std::pair< page_no_t, page_no_t >
 

Public Member Functions

 Page_extent (Btree_load *btree_load, const bool is_leaf)
 Constructor. More...
 
 ~Page_extent ()
 Destructor. More...
 
bool is_btree_load_nullptr () const
 
page_no_t page_count () const
 Number of pages in this extent. More...
 
void reset_range (const Page_range_t &range)
 Reset the range with the given value. More...
 
size_t used_pages () const
 Calculate the number of used pages. More...
 
void get_page_numbers (std::vector< page_no_t > &page_numbers) const
 
size_t last () const
 Get the index of the first unused page load. More...
 
bool is_valid () const
 Check if the range is valid. More...
 
bool is_null () const
 
Page_loadget_page_load (page_no_t page_no)
 Member of Page_extent. More...
 
void set_page_load (page_no_t page_no, Page_load *page_load)
 Member of Page_extent. More...
 
Page_range_t pages_to_free () const
 
void init ()
 Initialize the next page number to be allocated. More...
 
bool is_fully_used () const
 Check if no more pages are there to be used. More...
 
bool is_any_used () const
 Check if there are any pages used. More...
 
page_no_t alloc ()
 Allocate a page number. More...
 
void append (Page_load *page_load)
 Save a page_load. More...
 
dberr_t flush (fil_node_t *node, void *iov, size_t iov_size)
 Flush the used pages to disk. More...
 
dberr_t flush_one_by_one (fil_node_t *node)
 Flush one page at a time. More...
 
dberr_t bulk_flush (fil_node_t *node, void *iov, size_t iov_size)
 Flush 1 extent pages at a time. More...
 
dberr_t destroy ()
 Free all resources. More...
 
void destroy_cached ()
 Free any cached page load entries. More...
 
space_id_t space () const
 
void set_cached ()
 Mark the extent as cached. More...
 
void set_state (bool free)
 Set and unset free state of a cached extent. More...
 
bool is_free () const
 
bool is_cached () const
 
void reset_cached_page_loads ()
 Reset page load cache to free all. More...
 
std::ostream & print (std::ostream &out) const
 
void set_blob ()
 Mark that this extent is used for blobs. More...
 
bool is_blob () const
 Check if this is a blob extent. More...
 
void free_memory_blocks ()
 Free the BUF_BLOCK_MEMORY blocks used by this extent. More...
 

Static Public Member Functions

static Page_extentcreate (Btree_load *btree_load, const bool is_leaf, const bool is_blob)
 Create an object of type Page_extent in the heap. More...
 
static void drop (Page_extent *extent)
 Release the page extent. More...
 

Public Attributes

page_no_t m_page_no {FIL_NULL}
 Next page number to be used. More...
 
Page_range_t m_range {FIL_NULL, FIL_NULL}
 Page numbers of the pages that has been allocated in this extent. More...
 
std::vector< Page_load * > m_page_loads
 All the page loaders of the used pages. More...
 
std::atomic_bool m_is_owned_by_bulk_flusher {false}
 True if this extent has been handed over to the bulk flusher. More...
 

Private Attributes

Btree_loadm_btree_load {nullptr}
 
bool m_is_leaf {true}
 true if this extent belongs to leaf segment. More...
 
std::atomic_bool m_is_cached {false}
 true iff the the extent is cached. More...
 
std::atomic_bool m_is_free {true}
 true if the cached entry is free to be used. More...
 
std::vector< Page_load * > m_cached_page_loads
 Cached page loads. More...
 
size_t m_next_cached_page_load_index {0}
 Next cached page load index. More...
 
bool m_is_blob {false}
 True if this extent is used for blobs. More...
 

Friends

struct Level_ctx
 

Detailed Description

Allocate, use, manage and flush one extent pages (FSP_EXTENT_SIZE).

Member Typedef Documentation

◆ Page_range_t

Constructor & Destructor Documentation

◆ Page_extent()

Btree_multi::Page_extent::Page_extent ( Btree_load btree_load,
const bool  is_leaf 
)
inline

Constructor.

Parameters
[in]btree_loadB-tree loader object.
[in]is_leaftrue if this is part of leaf segment, false if this is part of non-leaf (or top) segment.

◆ ~Page_extent()

Btree_multi::Page_extent::~Page_extent ( )
inline

Destructor.

Member Function Documentation

◆ alloc()

page_no_t Btree_multi::Page_extent::alloc ( )
inline

Allocate a page number.

◆ append()

void Btree_multi::Page_extent::append ( Page_load page_load)
inline

Save a page_load.

◆ bulk_flush()

dberr_t Btree_multi::Page_extent::bulk_flush ( fil_node_t node,
void *  iov,
size_t  iov_size 
)

Flush 1 extent pages at a time.

Internally it will call OS dependent API (either bulk_flush_win() on Windows or bulk_flush_linux() on other operating systems.

Parameters
[in,out]nodespace file node
[in,out]iovvector IO array
[in]iov_sizevector IO array size
Returns
DB_SUCCESS on success, error code on failure.

◆ create()

Page_extent * Btree_multi::Page_extent::create ( Btree_load btree_load,
const bool  is_leaf,
const bool  is_blob 
)
inlinestatic

Create an object of type Page_extent in the heap.

◆ destroy()

dberr_t Btree_multi::Page_extent::destroy ( )

Free all resources.

◆ destroy_cached()

void Btree_multi::Page_extent::destroy_cached ( )

Free any cached page load entries.

◆ drop()

void Btree_multi::Page_extent::drop ( Page_extent extent)
inlinestatic

Release the page extent.

Delete if not cached.

Parameters
[in]extentextent to release

◆ flush()

dberr_t Btree_multi::Page_extent::flush ( fil_node_t node,
void *  iov,
size_t  iov_size 
)

Flush the used pages to disk.

It also frees the unused pages back to the segment.

Parameters
[in,out]nodespace file node
[in,out]iovvector IO array
[in]iov_sizevector IO array size
Returns
On success, return DB_SUCCESS.

◆ flush_one_by_one()

dberr_t Btree_multi::Page_extent::flush_one_by_one ( fil_node_t node)

Flush one page at a time.

This can be used when scatter/gather i/o is not available for use.

Parameters
[in,out]nodespace file node
Returns
On success, return DB_SUCCESS.

◆ free_memory_blocks()

void Btree_multi::Page_extent::free_memory_blocks ( )
inline

Free the BUF_BLOCK_MEMORY blocks used by this extent.

◆ get_page_load()

Page_load * Btree_multi::Page_extent::get_page_load ( page_no_t  page_no)
inline

Member of Page_extent.

The index of page_load objects in the m_page_loads corresponds to the page_no in the m_range. Here, check if a page_no already has a Page_load object.

Parameters
[in]page_nopage_no for which we are looking for Page_load obj.
Returns
Page_load object if available, nullptr otherwise.

◆ get_page_numbers()

void Btree_multi::Page_extent::get_page_numbers ( std::vector< page_no_t > &  page_numbers) const
inline

◆ init()

void Btree_multi::Page_extent::init ( void  )
inline

Initialize the next page number to be allocated.

The page range should have been already initialized.

◆ is_any_used()

bool Btree_multi::Page_extent::is_any_used ( ) const
inline

Check if there are any pages used.

Returns
true if at least one page is used.
false if no pages are used in this extent.

◆ is_blob()

bool Btree_multi::Page_extent::is_blob ( ) const
inline

Check if this is a blob extent.

Returns
true if it is a blob extent.

◆ is_btree_load_nullptr()

bool Btree_multi::Page_extent::is_btree_load_nullptr ( ) const
inline

◆ is_cached()

bool Btree_multi::Page_extent::is_cached ( ) const
inline
Returns
true iff it is a cached extent.

◆ is_free()

bool Btree_multi::Page_extent::is_free ( ) const
inline
Returns
true iff the cached element is in free state.

◆ is_fully_used()

bool Btree_multi::Page_extent::is_fully_used ( ) const
inline

Check if no more pages are there to be used.

Returns
true if the page extent is completely used.
false if the page extent has more pages to be used.

◆ is_null()

bool Btree_multi::Page_extent::is_null ( ) const
inline

◆ is_valid()

bool Btree_multi::Page_extent::is_valid ( void  ) const
inline

Check if the range is valid.

Returns
true if the range is valid, false otherwise.

◆ last()

size_t Btree_multi::Page_extent::last ( ) const
inline

Get the index of the first unused page load.

Returns
index of the first unused page load.

◆ page_count()

page_no_t Btree_multi::Page_extent::page_count ( ) const
inline

Number of pages in this extent.

◆ pages_to_free()

Page_range_t Btree_multi::Page_extent::pages_to_free ( ) const

◆ print()

std::ostream & Btree_multi::Page_extent::print ( std::ostream &  out) const
inline

◆ reset_cached_page_loads()

void Btree_multi::Page_extent::reset_cached_page_loads ( )
inline

Reset page load cache to free all.

◆ reset_range()

void Btree_multi::Page_extent::reset_range ( const Page_range_t range)
inline

Reset the range with the given value.

Parameters
[in]rangenew range value to be used.

◆ set_blob()

void Btree_multi::Page_extent::set_blob ( )
inline

Mark that this extent is used for blobs.

◆ set_cached()

void Btree_multi::Page_extent::set_cached ( )
inline

Mark the extent as cached.

Flush thread should not free this extent.

◆ set_page_load()

void Btree_multi::Page_extent::set_page_load ( page_no_t  page_no,
Page_load page_load 
)
inline

Member of Page_extent.

Associate the given page_no and the page load object.

Parameters
[in]page_nopage number to associate.
[in]page_loadpage load object to associate.

◆ set_state()

void Btree_multi::Page_extent::set_state ( bool  free)
inline

Set and unset free state of a cached extent.

Parameters
[in]freestate to be set

◆ space()

space_id_t Btree_multi::Page_extent::space ( ) const
inline

◆ used_pages()

size_t Btree_multi::Page_extent::used_pages ( ) const
inline

Calculate the number of used pages.

return the number of used pages.

Friends And Related Function Documentation

◆ Level_ctx

friend struct Level_ctx
friend

Member Data Documentation

◆ m_btree_load

Btree_load* Btree_multi::Page_extent::m_btree_load {nullptr}
private

◆ m_cached_page_loads

std::vector<Page_load *> Btree_multi::Page_extent::m_cached_page_loads
private

Cached page loads.

◆ m_is_blob

bool Btree_multi::Page_extent::m_is_blob {false}
private

True if this extent is used for blobs.

◆ m_is_cached

std::atomic_bool Btree_multi::Page_extent::m_is_cached {false}
private

true iff the the extent is cached.

◆ m_is_free

std::atomic_bool Btree_multi::Page_extent::m_is_free {true}
private

true if the cached entry is free to be used.

◆ m_is_leaf

bool Btree_multi::Page_extent::m_is_leaf {true}
private

true if this extent belongs to leaf segment.

◆ m_is_owned_by_bulk_flusher

std::atomic_bool Btree_multi::Page_extent::m_is_owned_by_bulk_flusher {false}

True if this extent has been handed over to the bulk flusher.

◆ m_next_cached_page_load_index

size_t Btree_multi::Page_extent::m_next_cached_page_load_index {0}
private

Next cached page load index.

◆ m_page_loads

std::vector<Page_load *> Btree_multi::Page_extent::m_page_loads

All the page loaders of the used pages.

◆ m_page_no

page_no_t Btree_multi::Page_extent::m_page_no {FIL_NULL}

Next page number to be used.

◆ m_range

Page_range_t Btree_multi::Page_extent::m_range {FIL_NULL, FIL_NULL}

Page numbers of the pages that has been allocated in this extent.

The page range is [p1, p2), where p2 is not included.


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