MySQL 9.1.0
Source Code Documentation
|
#include <btr0mtib.h>
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_t * | index () 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_t * | block_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_ctx * | get_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_copyable & | operator= (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_t * | m_index {} |
B-tree index. More... | |
fil_space_t * | m_space {} |
trx_t * | m_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_allocator & | m_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_t * | m_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_t * | m_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 |
using Btree_multi::Btree_load::Level_ctxs = std::vector<Level_ctx *, ut::allocator<Level_ctx *> > |
using Btree_multi::Btree_load::Page_loaders = std::vector<Page_load *, ut::allocator<Page_load *> > |
|
noexcept |
Constructor.
[in] | index | B-tree index. |
[in] | trx | Transaction object. |
[in] | loader_num | loader index |
[in] | flush_queue_size | bulk flusher queue size |
[in] | allocator | extent allocator |
|
noexcept |
Destructor.
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.
[in] | finish | if true, add all the tracked extents to the bulk flusher, irrespective of whether it is fully used or not. |
void Btree_load::add_to_bulk_flusher | ( | Page_extent * | page_extent | ) |
Add the given page extent object to the bulk flusher.
[in] | page_extent | the extent to be flushed. |
dberr_t Btree_load::alloc_extent | ( | Page_range_t & | page_range, |
size_t | level | ||
) |
Allocate an extent.
[in,out] | page_range | the range of pages allocated. |
[in] | level | btree level for which pages are allocated. |
|
inlinenoexcept |
Search for a BUF_BLOCK_MEMORY block with given page number in the local cache.
[in] | page_no | the page number of block to be fetched. |
|
inline |
Add the given block the internal cache of blocks.
[in] | block | the block to be cached. |
|
inline |
Remove the given block from the internal cache of blocks.
[in] | page_no | the page number of block to be removed from cache. |
dberr_t Btree_load::check_key_overlap | ( | const Btree_load * | r_btree | ) | const |
|
inline |
Indicate that the blob has been completed, so that resources can be removed, and as necessary flushing can be done.
[in] | blob_ctx | pointer to blob which has been completely written. |
[out] | ref | blob reference of the closed blob. |
|
inline |
If the data is already sorted and checked for duplicates, then we can disable doing it again.
|
noexcept |
Initiate a direct file write operation.
[in] | block | block to be written to disk. |
Btree page bulk load finish.
Commits the last page in each level if no error occurs. Also releases all page bulks.
[in] | is_err | Whether bulk load was successful until now |
[out] | last_page_no | Last page number |
|
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.
[in] | is_err | Whether bulk load was successful until now |
[in] | subtree | true if a subtree is being built, false otherwise. |
|
noexcept |
Flush the blob pages.
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.
[in] | range | range of page numbers. |
[in] | dirty_is_ok | it is OK for a page to be dirty. |
|
inline |
Get the level context object.
[in] | level | the level number. level 0 is leaf level. |
|
inline |
|
inline |
Get the level of the root page.
void Btree_load::get_root_page_stat | ( | Page_stat & | stat | ) |
Get information about root page.
|
inline |
Get the root page number of this tree/subtree.
|
inline |
trx_id_t Btree_load::get_trx_id | ( | ) | const |
Get the transaction id.
|
inline |
Get the index object.
dberr_t Btree_load::init | ( | void | ) |
Initialize.
Allocates the m_heap_order memory heap.
Insert a tuple to a page in a level.
[in] | dtuple | Tuple to insert |
[in] | level | B-tree level |
|
noexcept |
Insert a tuple to a page.
[in] | page_load | Page bulk object |
[in] | tuple | Tuple to insert |
[in] | big_rec | Big record vector, maybe NULL if there is no Data to be stored externally. |
[in] | rec_size | Record size |
|
inline |
|
inlineprivate |
bool Btree_load::is_interrupted | ( | ) | const |
Check if the index build operation has been interrupted.
|
inline |
Check if a new level is needed.
bool Btree_load::is_tpc_enabled | ( | ) | const |
Check if transparent page compression (TPC) is enabled.
bool Btree_load::is_tpe_enabled | ( | ) | const |
Check if transparent page encryption (TPE) is enabled.
Set the root page on completion.
[in] | last_page_no | Last page number (the new root). |
|
inline |
Create a blob.
[out] | blob_ctx | pointer to an opaque object representing a blob. |
[out] | ref | blob reference to be placed in the record. |
|
noexcept |
Commit(finish) a page.
We set next/prev page no, insert a node pointer to father page if needed, and commit mini-transaction.
[in] | page_load | Page to commit |
[in] | next_page_load | Next page |
[in] | insert_father | Flag whether need to insert node ptr |
|
noexcept |
Prepare space to insert a tuple.
[in,out] | page_load | Page bulk that will be used to store the record. It may be replaced if there is not enough space to hold the record. |
[in] | level | B-tree level |
[in] | rec_size | Record size |
std::ostream & Btree_load::print_left_pages | ( | std::ostream & | out | ) | const |
std::string Btree_load::print_pages_in_level | ( | const size_t | level | ) | const |
std::ostream & Btree_load::print_right_pages | ( | std::ostream & | out | ) | const |
void Btree_load::print_tree_pages | ( | ) | const |
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.
[in,out] | block | the left most block at the given level. it will be updated with the new left most block. |
[in] | level | level of the given block. |
[in] | node_ptr | node pointer to be inserted in the block after splitting. |
[in] | mtr | mini transaction context. |
[in,out] | highest_level | highest level among all the subtrees. |
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.
[in,out] | block | the right most block at the given level. |
[in] | level | level of the given block. |
[in] | node_ptr | node pointer to be inserted in the block after splitting. |
[in] | mtr | mini transaction context. |
[in,out] | highest_level | highest level among all the subtrees. |
void Btree_load::track_extent | ( | Page_extent * | page_extent | ) |
All allocated extents registers with Btree_load.
|
inline |
Save flushed page numbers for debugging purposes.
[in] | page_no | page number of the page that is flushed. |
|
inline |
Trigger flusher thread and check for error.
|
static |
Check size and validate index of limited size.
[in] | index | Index to validate |
|
inline |
Write data into the blob.
[in] | blob_ctx | pointer to blob into which data is written. |
[in,out] | ref | blob reference of the current blob |
[in] | data | buffer containing data to be written |
[in] | len | length of the data to be written. |
|
friend |
|
private |
Page allocation type.
We allocate in extents by default.
|
private |
Reference to global extent allocator.
|
private |
Blob inserter that will be used to handle all the externally stored fields of InnoDB.
|
private |
|
private |
If true, check if data is inserted in sorted order.
|
private |
Function object to compare two tuples.
|
private |
Extents that are being tracked.
std::vector<page_no_t, ut::allocator<page_no_t> > Btree_multi::Btree_load::m_first_page_nos {} |
First page numbers of each level.
|
private |
|
private |
byte Btree_multi::Btree_load::m_fseg_hdr_leaf[FSEG_HEADER_SIZE] |
byte Btree_multi::Btree_load::m_fseg_hdr_top[FSEG_HEADER_SIZE] |
|
private |
Memory heap to be used for sort order checks.
|
private |
B-tree index.
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
std::vector<page_no_t, ut::allocator<page_no_t> > Btree_multi::Btree_load::m_last_page_nos {} |
Last page numbers of each level.
|
private |
Context information for each level of the B-tree.
The leaf level is at m_level_ctxs[0].
|
private |
Loader number.
|
private |
Number of records inserted.
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.
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.
|
private |
|
private |
The previous tuple that has been inserted.
|
private |
Root page level.
|
private |
size_t Btree_multi::Btree_load::m_stat_n_extents {0} |
Number of extents allocated for this B-tree.
size_t Btree_multi::Btree_load::m_stat_n_pages {0} |
Number of pages allocated for this B-tree.
|
private |
Transaction id.