MySQL 9.1.0
Source Code Documentation
Btree_multi::Btree_load Class Reference

#include <btr0mtib.h>

Inheritance diagram for Btree_multi::Btree_load:
[legend]

Classes

class  Merger
 
class  Wait_callbacks
 Helper to set wait callbacks for the current scope. More...
 

Public Types

using Page_loaders = std::vector< Page_load *, ut::allocator< Page_load * > >
 
using Level_ctxs = std::vector< Level_ctx *, ut::allocator< Level_ctx * > >
 

Public Member Functions

dberr_t insert_blob (lob::ref_t &ref, const dfield_t *dfield)
 
dberr_t open_blob (Blob_context &blob_ctx, lob::ref_t &ref)
 Create a blob. More...
 
dberr_t write_blob (Blob_context blob_ctx, lob::ref_t &ref, const byte *data, size_t len)
 Write data into the blob. More...
 
dberr_t close_blob (Blob_context blob_ctx, lob::ref_t &ref)
 Indicate that the blob has been completed, so that resources can be removed, and as necessary flushing can be done. More...
 
 Btree_load (dict_index_t *index, trx_t *trx, size_t loader_num, size_t flush_queue_size, Bulk_extent_allocator &allocator) noexcept
 Constructor. More...
 
 ~Btree_load () noexcept
 Destructor. More...
 
dberr_t init ()
 Initialize. More...
 
void track_page_flush (page_no_t page_no)
 Save flushed page numbers for debugging purposes. More...
 
bool is_interrupted () const
 Check if the index build operation has been interrupted. More...
 
dberr_t trigger_flusher () const
 Trigger flusher thread and check for error. More...
 
dict_index_tindex () const
 Get the index object. More...
 
const char * get_table_name () const
 
page_no_t get_subtree_root () const
 Get the root page number of this tree/subtree. More...
 
size_t get_root_level () const
 Get the level of the root page. More...
 
void get_root_page_stat (Page_stat &stat)
 Get information about root page. More...
 
trx_id_t get_trx_id () const
 Get the transaction id. More...
 
dberr_t finish (bool is_err, const bool subtree) noexcept
 Btree bulk load finish. More...
 
dberr_t insert (dtuple_t *dtuple, size_t level) noexcept
 Insert a tuple to a page in a level. More...
 
void split_rightmost (buf_block_t *block, size_t level, dtuple_t *node_ptr, mtr_t *mtr, size_t &highest_level)
 Split the right most block of the tree at the given level. More...
 
void split_leftmost (buf_block_t *&block, size_t level, dtuple_t *node_ptr, mtr_t *mtr, size_t &highest_level)
 Split the left most block of the tree at the given level. More...
 
dberr_t page_commit (Page_load *page_load, Page_load *next_page_load, bool insert_father) noexcept
 Commit(finish) a page. More...
 
dberr_t prepare_space (Page_load *&page_load, size_t level, size_t rec_size) noexcept
 Prepare space to insert a tuple. More...
 
dberr_t insert (Page_load *page_load, dtuple_t *tuple, big_rec_t *big_rec, size_t rec_size) noexcept
 Insert a tuple to a page. More...
 
dberr_t finalize_page_loads (bool is_err, page_no_t &last_page_no) noexcept
 Btree page bulk load finish. More...
 
dberr_t alloc_extent (Page_range_t &page_range, size_t level)
 Allocate an extent. More...
 
dberr_t fil_io (buf_block_t *block) noexcept
 Initiate a direct file write operation. More...
 
dberr_t flush_blobs () noexcept
 Flush the blob pages. More...
 
void block_put (buf_block_t *block)
 Add the given block the internal cache of blocks. More...
 
void block_remove (const page_no_t page_no)
 Remove the given block from the internal cache of blocks. More...
 
buf_block_tblock_get (page_no_t page_no) const noexcept
 Search for a BUF_BLOCK_MEMORY block with given page number in the local cache. More...
 
void force_evict (const Page_range_t &range, const bool dirty_is_ok=true)
 Evict all the pages in the given range from the buffer pool. More...
 
bool is_new_level (size_t level) const
 Check if a new level is needed. More...
 
Level_ctxget_level (size_t level) const
 Get the level context object. More...
 
std::ostream & print_left_pages (std::ostream &out) const
 
std::ostream & print_right_pages (std::ostream &out) const
 
dberr_t check_key_overlap (const Btree_load *r_btree) const
 
void print_tree_pages () const
 
std::string print_pages_in_level (const size_t level) const
 
void track_extent (Page_extent *page_extent)
 All allocated extents registers with Btree_load. More...
 
void add_to_bulk_flusher (bool finish=false)
 Add fully used extents to the bulk flusher. More...
 
void add_to_bulk_flusher (Page_extent *page_extent)
 Add the given page extent object to the bulk flusher. More...
 
bool is_tpc_enabled () const
 Check if transparent page compression (TPC) is enabled. More...
 
bool is_tpe_enabled () const
 Check if transparent page encryption (TPE) is enabled. More...
 
size_t get_max_flush_queue_size () const
 
void disable_check_order ()
 If the data is already sorted and checked for duplicates, then we can disable doing it again. More...
 

Static Public Member Functions

static bool validate_index (dict_index_t *index)
 Check size and validate index of limited size. More...
 

Public Attributes

std::vector< page_no_t, ut::allocator< page_no_t > > m_last_page_nos {}
 Last page numbers of each level. More...
 
std::vector< page_no_t, ut::allocator< page_no_t > > m_first_page_nos {}
 First page numbers of each level. More...
 
Page_range_t m_page_range_leaf {}
 Page numbers of the pages that has been allocated in the leaf level. More...
 
Page_range_t m_page_range_top {}
 Page numbers of the pages that has been allocated in the non-leaf level. More...
 
byte m_fseg_hdr_leaf [FSEG_HEADER_SIZE]
 
byte m_fseg_hdr_top [FSEG_HEADER_SIZE]
 
unsigned m_index_online {}
 State of the index. More...
 
size_t m_stat_n_extents {0}
 Number of extents allocated for this B-tree. More...
 
size_t m_stat_n_pages {0}
 Number of pages allocated for this B-tree. More...
 

Private Member Functions

dberr_t load_root_page (page_no_t last_page_no) noexcept
 Set the root page on completion. More...
 
bool is_extent_tracked (const Page_extent *page_extent) const
 
- Private Member Functions inherited from ut::Non_copyable
 Non_copyable (const Non_copyable &)=delete
 
Non_copyableoperator= (const Non_copyable &)=delete
 
 Non_copyable ()=default
 
 ~Non_copyable ()=default
 

Private Attributes

Bulk_extent_allocator::Type m_alloc_type
 Page allocation type. More...
 
uint64_t m_n_recs {}
 Number of records inserted. More...
 
dict_index_tm_index {}
 B-tree index. More...
 
fil_space_tm_space {}
 
trx_tm_trx {}
 Transaction id. More...
 
size_t m_root_level {}
 Root page level. More...
 
Level_ctxs m_level_ctxs {}
 Context information for each level of the B-tree. More...
 
Bulk_extent_allocatorm_allocator
 Reference to global extent allocator. More...
 
std::list< Page_extent * > m_extents_tracked
 Extents that are being tracked. More...
 
bool m_check_order {true}
 If true, check if data is inserted in sorted order. More...
 
mem_heap_tm_heap_order {}
 Memory heap to be used for sort order checks. More...
 
ddl::Compare_key m_compare_key
 Function object to compare two tuples. More...
 
dtuple_tm_prev_tuple {}
 The previous tuple that has been inserted. More...
 
size_t m_loader_num {}
 Loader number. More...
 
const page_size_t m_page_size
 
Wait_callbacks::Function m_fn_wait_begin
 
Wait_callbacks::Function m_fn_wait_end
 
bulk::Blob_inserter m_blob_inserter
 Blob inserter that will be used to handle all the externally stored fields of InnoDB. More...
 
Bulk_flusher m_bulk_flusher
 

Friends

class bulk::Blob_inserter
 

Detailed Description

Note
We should call commit(false) for a Page_load object, which is not in m_page_loaders after page_commit, and we will commit or abort Page_load objects in function "finish".

Member Typedef Documentation

◆ Level_ctxs

◆ Page_loaders

Constructor & Destructor Documentation

◆ Btree_load()

Btree_load::Btree_load ( dict_index_t index,
trx_t trx,
size_t  loader_num,
size_t  flush_queue_size,
Bulk_extent_allocator allocator 
)
noexcept

Constructor.

Parameters
[in]indexB-tree index.
[in]trxTransaction object.
[in]loader_numloader index
[in]flush_queue_sizebulk flusher queue size
[in]allocatorextent allocator

◆ ~Btree_load()

Btree_load::~Btree_load ( )
noexcept

Destructor.

Member Function Documentation

◆ add_to_bulk_flusher() [1/2]

void Btree_load::add_to_bulk_flusher ( bool  finish = false)

Add fully used extents to the bulk flusher.

Call this whenever a new Page_load is allocated, with finish set to false. Only in Btree_load::finish(), the finish argument will be true.

Parameters
[in]finishif true, add all the tracked extents to the bulk flusher, irrespective of whether it is fully used or not.

◆ add_to_bulk_flusher() [2/2]

void Btree_load::add_to_bulk_flusher ( Page_extent page_extent)

Add the given page extent object to the bulk flusher.

Parameters
[in]page_extentthe extent to be flushed.

◆ alloc_extent()

dberr_t Btree_load::alloc_extent ( Page_range_t page_range,
size_t  level 
)

Allocate an extent.

Parameters
[in,out]page_rangethe range of pages allocated.
[in]levelbtree level for which pages are allocated.
Returns
status code.

◆ block_get()

buf_block_t * Btree_multi::Btree_load::block_get ( page_no_t  page_no) const
inlinenoexcept

Search for a BUF_BLOCK_MEMORY block with given page number in the local cache.

Parameters
[in]page_nothe page number of block to be fetched.
Returns
buffer block with given page number.

◆ block_put()

void Btree_multi::Btree_load::block_put ( buf_block_t block)
inline

Add the given block the internal cache of blocks.

Parameters
[in]blockthe block to be cached.

◆ block_remove()

void Btree_multi::Btree_load::block_remove ( const page_no_t  page_no)
inline

Remove the given block from the internal cache of blocks.

Parameters
[in]page_nothe page number of block to be removed from cache.

◆ check_key_overlap()

dberr_t Btree_load::check_key_overlap ( const Btree_load r_btree) const

◆ close_blob()

dberr_t Btree_multi::Btree_load::close_blob ( Blob_context  blob_ctx,
lob::ref_t ref 
)
inline

Indicate that the blob has been completed, so that resources can be removed, and as necessary flushing can be done.

Parameters
[in]blob_ctxpointer to blob which has been completely written.
[out]refblob reference of the closed blob.
Returns
DB_SUCCESS on success or a failure error code.

◆ disable_check_order()

void Btree_multi::Btree_load::disable_check_order ( )
inline

If the data is already sorted and checked for duplicates, then we can disable doing it again.

◆ fil_io()

dberr_t Btree_multi::Btree_load::fil_io ( buf_block_t block)
noexcept

Initiate a direct file write operation.

Parameters
[in]blockblock to be written to disk.
Returns
error code.

◆ finalize_page_loads()

dberr_t Btree_load::finalize_page_loads ( bool  is_err,
page_no_t last_page_no 
)
noexcept

Btree page bulk load finish.

Commits the last page in each level if no error occurs. Also releases all page bulks.

Parameters
[in]is_errWhether bulk load was successful until now
[out]last_page_noLast page number
Returns
error code

◆ finish()

dberr_t Btree_load::finish ( bool  is_err,
const bool  subtree 
)
noexcept

Btree bulk load finish.

We commit the last page in each level and copy the last page in top level to the root page of the index if no error occurs.

Parameters
[in]is_errWhether bulk load was successful until now
[in]subtreetrue if a subtree is being built, false otherwise.
Returns
error code

◆ flush_blobs()

dberr_t Btree_multi::Btree_load::flush_blobs ( )
noexcept

Flush the blob pages.

Returns
status code.

◆ force_evict()

void Btree_load::force_evict ( const Page_range_t range,
const bool  dirty_is_ok = true 
)

Evict all the pages in the given range from the buffer pool.

Parameters
[in]rangerange of page numbers.
[in]dirty_is_okit is OK for a page to be dirty.

◆ get_level()

Level_ctx * Btree_load::get_level ( size_t  level) const
inline

Get the level context object.

Parameters
[in]levelthe level number. level 0 is leaf level.
Returns
the level context object.

◆ get_max_flush_queue_size()

size_t Btree_multi::Btree_load::get_max_flush_queue_size ( ) const
inline
Returns
get flush queue size limit.

◆ get_root_level()

size_t Btree_multi::Btree_load::get_root_level ( ) const
inline

Get the level of the root page.

Returns
the level of the root page.

◆ get_root_page_stat()

void Btree_load::get_root_page_stat ( Page_stat stat)

Get information about root page.

◆ get_subtree_root()

page_no_t Btree_multi::Btree_load::get_subtree_root ( ) const
inline

Get the root page number of this tree/subtree.

Returns
the root page number of this tree/subtree.

◆ get_table_name()

const char * Btree_multi::Btree_load::get_table_name ( ) const
inline

◆ get_trx_id()

trx_id_t Btree_load::get_trx_id ( ) const

Get the transaction id.

Returns
the transaction id.

◆ index()

dict_index_t * Btree_multi::Btree_load::index ( ) const
inline

Get the index object.

Returns
index object.

◆ init()

dberr_t Btree_load::init ( void  )

Initialize.

Allocates the m_heap_order memory heap.

Returns
DB_SUCCESS on success or an error code on failure.

◆ insert() [1/2]

dberr_t Btree_load::insert ( dtuple_t dtuple,
size_t  level 
)
noexcept

Insert a tuple to a page in a level.

Parameters
[in]dtupleTuple to insert
[in]levelB-tree level
Returns
error code

◆ insert() [2/2]

dberr_t Btree_load::insert ( Page_load page_load,
dtuple_t tuple,
big_rec_t big_rec,
size_t  rec_size 
)
noexcept

Insert a tuple to a page.

Parameters
[in]page_loadPage bulk object
[in]tupleTuple to insert
[in]big_recBig record vector, maybe NULL if there is no Data to be stored externally.
[in]rec_sizeRecord size
Returns
error code

◆ insert_blob()

dberr_t Btree_multi::Btree_load::insert_blob ( lob::ref_t ref,
const dfield_t dfield 
)
inline

◆ is_extent_tracked()

bool Btree_load::is_extent_tracked ( const Page_extent page_extent) const
inlineprivate

◆ is_interrupted()

bool Btree_load::is_interrupted ( ) const

Check if the index build operation has been interrupted.

Returns
true if the index build operation is interrupted, false otherwise.

◆ is_new_level()

bool Btree_multi::Btree_load::is_new_level ( size_t  level) const
inline

Check if a new level is needed.

◆ is_tpc_enabled()

bool Btree_load::is_tpc_enabled ( ) const

Check if transparent page compression (TPC) is enabled.

Returns
true if TPC is enabled.

◆ is_tpe_enabled()

bool Btree_load::is_tpe_enabled ( ) const

Check if transparent page encryption (TPE) is enabled.

Returns
true if TPE is enabled.

◆ load_root_page()

dberr_t Btree_load::load_root_page ( page_no_t  last_page_no)
privatenoexcept

Set the root page on completion.

Parameters
[in]last_page_noLast page number (the new root).
Returns
DB_SUCCESS or error code.

◆ open_blob()

dberr_t Btree_multi::Btree_load::open_blob ( Blob_context blob_ctx,
lob::ref_t ref 
)
inline

Create a blob.

Parameters
[out]blob_ctxpointer to an opaque object representing a blob.
[out]refblob reference to be placed in the record.
Returns
DB_SUCCESS on success or a failure error code.

◆ page_commit()

dberr_t Btree_load::page_commit ( Page_load page_load,
Page_load next_page_load,
bool  insert_father 
)
noexcept

Commit(finish) a page.

We set next/prev page no, insert a node pointer to father page if needed, and commit mini-transaction.

Parameters
[in]page_loadPage to commit
[in]next_page_loadNext page
[in]insert_fatherFlag whether need to insert node ptr
Returns
error code

◆ prepare_space()

dberr_t Btree_load::prepare_space ( Page_load *&  page_load,
size_t  level,
size_t  rec_size 
)
noexcept

Prepare space to insert a tuple.

Parameters
[in,out]page_loadPage bulk that will be used to store the record. It may be replaced if there is not enough space to hold the record.
[in]levelB-tree level
[in]rec_sizeRecord size
Returns
error code

◆ print_left_pages()

std::ostream & Btree_load::print_left_pages ( std::ostream &  out) const

◆ print_pages_in_level()

std::string Btree_load::print_pages_in_level ( const size_t  level) const

◆ print_right_pages()

std::ostream & Btree_load::print_right_pages ( std::ostream &  out) const

◆ print_tree_pages()

void Btree_load::print_tree_pages ( ) const

◆ split_leftmost()

void Btree_load::split_leftmost ( buf_block_t *&  block,
size_t  level,
dtuple_t node_ptr,
mtr_t mtr,
size_t &  highest_level 
)

Split the left most block of the tree at the given level.

Parameters
[in,out]blockthe left most block at the given level. it will be updated with the new left most block.
[in]levellevel of the given block.
[in]node_ptrnode pointer to be inserted in the block after splitting.
[in]mtrmini transaction context.
[in,out]highest_levelhighest level among all the subtrees.

◆ split_rightmost()

void Btree_load::split_rightmost ( buf_block_t block,
size_t  level,
dtuple_t node_ptr,
mtr_t mtr,
size_t &  highest_level 
)

Split the right most block of the tree at the given level.

Parameters
[in,out]blockthe right most block at the given level.
[in]levellevel of the given block.
[in]node_ptrnode pointer to be inserted in the block after splitting.
[in]mtrmini transaction context.
[in,out]highest_levelhighest level among all the subtrees.

◆ track_extent()

void Btree_load::track_extent ( Page_extent page_extent)

All allocated extents registers with Btree_load.


◆ track_page_flush()

void Btree_multi::Btree_load::track_page_flush ( page_no_t  page_no)
inline

Save flushed page numbers for debugging purposes.

Parameters
[in]page_nopage number of the page that is flushed.

◆ trigger_flusher()

dberr_t Btree_multi::Btree_load::trigger_flusher ( ) const
inline

Trigger flusher thread and check for error.

Returns
Innodb error code.

◆ validate_index()

bool Btree_load::validate_index ( dict_index_t index)
static

Check size and validate index of limited size.

Parameters
[in]indexIndex to validate
Returns
true if successful.

◆ write_blob()

dberr_t Btree_multi::Btree_load::write_blob ( Blob_context  blob_ctx,
lob::ref_t ref,
const byte data,
size_t  len 
)
inline

Write data into the blob.

Parameters
[in]blob_ctxpointer to blob into which data is written.
[in,out]refblob reference of the current blob
[in]databuffer containing data to be written
[in]lenlength of the data to be written.
Returns
DB_SUCCESS on success or a failure error code.

Friends And Related Function Documentation

◆ bulk::Blob_inserter

friend class bulk::Blob_inserter
friend

Member Data Documentation

◆ m_alloc_type

Bulk_extent_allocator::Type Btree_multi::Btree_load::m_alloc_type
private
Initial value:

Page allocation type.

We allocate in extents by default.

◆ m_allocator

Bulk_extent_allocator& Btree_multi::Btree_load::m_allocator
private

Reference to global extent allocator.

◆ m_blob_inserter

bulk::Blob_inserter Btree_multi::Btree_load::m_blob_inserter
private

Blob inserter that will be used to handle all the externally stored fields of InnoDB.

◆ m_bulk_flusher

Bulk_flusher Btree_multi::Btree_load::m_bulk_flusher
private

◆ m_check_order

bool Btree_multi::Btree_load::m_check_order {true}
private

If true, check if data is inserted in sorted order.

◆ m_compare_key

ddl::Compare_key Btree_multi::Btree_load::m_compare_key
private

Function object to compare two tuples.

◆ m_extents_tracked

std::list<Page_extent *> Btree_multi::Btree_load::m_extents_tracked
private

Extents that are being tracked.

◆ m_first_page_nos

std::vector<page_no_t, ut::allocator<page_no_t> > Btree_multi::Btree_load::m_first_page_nos {}

First page numbers of each level.

◆ m_fn_wait_begin

Wait_callbacks::Function Btree_multi::Btree_load::m_fn_wait_begin
private

◆ m_fn_wait_end

Wait_callbacks::Function Btree_multi::Btree_load::m_fn_wait_end
private

◆ m_fseg_hdr_leaf

byte Btree_multi::Btree_load::m_fseg_hdr_leaf[FSEG_HEADER_SIZE]

◆ m_fseg_hdr_top

byte Btree_multi::Btree_load::m_fseg_hdr_top[FSEG_HEADER_SIZE]

◆ m_heap_order

mem_heap_t* Btree_multi::Btree_load::m_heap_order {}
private

Memory heap to be used for sort order checks.

◆ m_index

dict_index_t* Btree_multi::Btree_load::m_index {}
private

B-tree index.

◆ m_index_online

unsigned Btree_multi::Btree_load::m_index_online {}

State of the index.

Used for asserting at the end of a bulk load operation to ensure that the online status of the index does not change

◆ m_last_page_nos

std::vector<page_no_t, ut::allocator<page_no_t> > Btree_multi::Btree_load::m_last_page_nos {}

Last page numbers of each level.

◆ m_level_ctxs

Level_ctxs Btree_multi::Btree_load::m_level_ctxs {}
private

Context information for each level of the B-tree.

The leaf level is at m_level_ctxs[0].

◆ m_loader_num

size_t Btree_multi::Btree_load::m_loader_num {}
private

Loader number.

◆ m_n_recs

uint64_t Btree_multi::Btree_load::m_n_recs {}
private

Number of records inserted.

◆ m_page_range_leaf

Page_range_t Btree_multi::Btree_load::m_page_range_leaf {}

Page numbers of the pages that has been allocated in the leaf level.

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

◆ m_page_range_top

Page_range_t Btree_multi::Btree_load::m_page_range_top {}

Page numbers of the pages that has been allocated in the non-leaf level.

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

◆ m_page_size

const page_size_t Btree_multi::Btree_load::m_page_size
private

◆ m_prev_tuple

dtuple_t* Btree_multi::Btree_load::m_prev_tuple {}
private

The previous tuple that has been inserted.

◆ m_root_level

size_t Btree_multi::Btree_load::m_root_level {}
private

Root page level.

◆ m_space

fil_space_t* Btree_multi::Btree_load::m_space {}
private

◆ m_stat_n_extents

size_t Btree_multi::Btree_load::m_stat_n_extents {0}

Number of extents allocated for this B-tree.

◆ m_stat_n_pages

size_t Btree_multi::Btree_load::m_stat_n_pages {0}

Number of pages allocated for this B-tree.

◆ m_trx

trx_t* Btree_multi::Btree_load::m_trx {}
private

Transaction id.


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