MySQL 8.4.2
Source Code Documentation
|
For loading indexes. More...
#include <ddl0impl-builder.h>
Classes | |
struct | Thread_ctx |
State of a cluster index reader thread. More... | |
Public Types | |
enum class | State : uint8_t { INIT , ADD , SETUP_SORT , SORT , BTREE_BUILD , FTS_SORT_AND_BUILD , FINISH , STOP , ERROR } |
Build phase/states. More... | |
Public Member Functions | |
Builder (ddl::Context &ctx, Loader &loader, size_t i) noexcept | |
Constructor. More... | |
~Builder () noexcept | |
Destructor/. More... | |
dberr_t | get_error () const noexcept |
void | set_error (dberr_t err) noexcept |
Set the error code. More... | |
size_t | id () const noexcept |
dict_index_t * | index () noexcept |
Context & | ctx () noexcept |
void | fallback_to_single_thread () noexcept |
Parallel scan thread spawn failed, release the extra thread states. More... | |
bool | is_spatial_index () const noexcept |
bool | is_fts_index () const noexcept |
bool | is_unique_index () const noexcept |
State | get_state () const noexcept |
void | set_state (State state) noexcept |
Set the next state. More... | |
Alter_stage * | stage () noexcept |
void | set_next_state () noexcept |
Set the next state. More... | |
dberr_t | init (Cursor &cursor, size_t n_threads) noexcept |
Initialize the cursor. More... | |
dberr_t | add_row (Cursor &cursor, Row &row, size_t thread_id, Latch_release &&latch_release) noexcept |
Add a row to the merge buffer. More... | |
bool | is_skip_file_sort () const noexcept |
dberr_t | fts_sort_and_build () noexcept |
FTS: Sort and insert the rows read. More... | |
dberr_t | setup_sort () noexcept |
Non-FTS: Sort the rows read. More... | |
dberr_t | merge_sort (size_t thread_id) noexcept |
Non-FTS: Sort the rows read. More... | |
dberr_t | btree_build () noexcept |
Load the sorted data into the B+Tree. More... | |
dberr_t | finish () noexcept |
Close temporary files, Flush all dirty pages, apply the row log and write the redo log record. More... | |
dberr_t | dtuple_copy_blobs (dtuple_t *dtuple, ulint *offsets, const mrec_t *mrec, mem_heap_t *heap) noexcept |
Copy blobs to the tuple. More... | |
dberr_t | append (ddl::file_t &file, IO_buffer file_buffer) noexcept |
Write data to disk - in append mode. More... | |
const char * | tmpdir () const noexcept |
dberr_t | batch_insert (size_t thread_id, Latch_release &&latch_release) noexcept |
Insert cached rows. More... | |
void | batch_insert_deep_copy_tuples (size_t thread_id) noexcept |
Note that the latches are going to be released. More... | |
dberr_t | check_state_of_online_build_log () noexcept |
Check the state of the online build log for the index. More... | |
Static Public Member Functions | |
static void | write_redo (const dict_index_t *index) noexcept |
Write an MLOG_INDEX_LOAD record to indicate in the redo-log that redo-logging of individual index pages was disabled, and the flushing of such pages to the data files was completed. More... | |
Private Types | |
using | Allocator = ut::allocator< Thread_ctx * > |
using | Thread_ctxs = std::vector< Thread_ctx *, Allocator > |
Private Member Functions | |
dberr_t | create_merge_sort_tasks () noexcept |
Create the tasks to merge Sort the file before we load the file into the Btree index. More... | |
dberr_t | finalize () noexcept |
Flush all dirty pages, apply the row log and write the redo log record. More... | |
dberr_t | batch_add_row (Row &row, size_t thread_id) noexcept |
Cache a row for batch inserts. More... | |
dberr_t | bulk_add_row (Cursor &cursor, Row &row, size_t thread_id, Latch_release &&latch_release) noexcept |
Add a row to the merge buffer. More... | |
void | clear_virtual_heap () noexcept |
Clear the heap used for virtual columns. More... | |
void | fts_add_doc_id (dfield_t *dst, const dict_field_t *src, doc_id_t &write_doc_id) noexcept |
Add the FTS document ID to the destination field. More... | |
dberr_t | copy_row (Copy_ctx &ctx, size_t &mv_rows_added) noexcept |
Add a row to the write buffer. More... | |
dberr_t | get_virtual_column (Copy_ctx &ctx, const dict_field_t *ifield, dict_col_t *col, dfield_t *&src_field, size_t &mv_rows_added) noexcept |
Setup the virtual column src column. More... | |
dberr_t | copy_fts_column (Copy_ctx &ctx, dfield_t *field) noexcept |
Copy the FTS columns. More... | |
dberr_t | copy_columns (Copy_ctx &ctx, size_t &mv_rows_added, doc_id_t &write_doc_id) noexcept |
Copy the columns to the temporary file buffer. More... | |
dberr_t | add_to_key_buffer (Copy_ctx &ctx, size_t &mv_rows_added) noexcept |
Add row to the key buffer. More... | |
void | fts_wait_for_completion (const dict_index_t *index) noexcept |
Wait for FTS completion. More... | |
dberr_t | key_buffer_sort (size_t thread_id) noexcept |
Sort the data in the key buffer. More... | |
dberr_t | insert_direct (Cursor &cursor, size_t thread_id) noexcept |
Sort the buffer in memory and insert directly in the BTree loader, don't write to a temporary file. More... | |
bool | create_file (ddl::file_t &file) noexcept |
Create the merge file, if needed. More... | |
dberr_t | check_duplicates (Thread_ctxs &dupcheck, Dup *dup) noexcept |
Check for duplicates in the first block. More... | |
dberr_t | online_build_handle_error (dberr_t err) noexcept |
Cleanup DDL after error in online build Note: To be called if DDL must cleanup due to error in online build. More... | |
Static Private Member Functions | |
static void | convert (const dict_index_t *clust_index, const dfield_t *row_field, dfield_t *field, ulint len, const page_size_t &page_size, bool is_sdi, mem_heap_t *heap) noexcept |
Convert the field data from compact to redundant format. More... | |
static void | copy_blobs (const dict_index_t *index, const mrec_t *mrec, const ulint *offsets, const page_size_t &page_size, dtuple_t *tuple, bool is_sdi, mem_heap_t *heap) noexcept |
Copy externally stored columns to the data tuple. More... | |
Private Attributes | |
size_t | m_id {} |
Buffer ID. More... | |
std::atomic< State > | m_state {State::INIT} |
Initial phase. More... | |
ddl::Context & | m_ctx |
DDL Context. More... | |
Loader & | m_loader |
Loader that owns the instance. More... | |
dict_index_t * | m_index {} |
Index to create (if not FTS index). More... | |
const char * | m_tmpdir {} |
Temporary file path. More... | |
Thread_ctxs | m_thread_ctxs {} |
Per thread context. More... | |
dfield_t * | m_prev_fields {} |
For tracking duplicates. More... | |
Dup | m_clust_dup {} |
For collecting duplicate entries (error reporting). More... | |
Scoped_heap | m_v_heap {} |
Scoped virtual column heap. More... | |
Scoped_heap | m_conv_heap {} |
Scoped conversion heap. More... | |
dict_index_t * | m_sort_index {} |
The index to be built, FTS or non-FTS. More... | |
std::atomic< size_t > | m_n_sort_tasks {} |
Number of active sort tasks. More... | |
Btree_load * | m_btr_load {} |
Cluster index bulk load instance to use, direct insert without a file sort. More... | |
Alter_stage * | m_local_stage {} |
Stage per builder. More... | |
For loading indexes.
|
private |
|
private |
|
strong |
Build phase/states.
|
noexcept |
Constructor.
[in,out] | ctx | DDL context. |
[in,out] | loader | Owner of the instance. |
[in] | i | Index ordinal value. |
|
noexcept |
Destructor/.
|
noexcept |
Add a row to the merge buffer.
[in,out] | cursor | Current scan cursor. |
[in,out] | row | Row to add. |
[in] | thread_id | ID of current thread. |
[in,out] | latch_release | Called when a log free check is required. |
Add row to the key buffer.
[in,out] | ctx | Copy context. |
[in,out] | mv_rows_added | Number of multi-value index rows added. |
|
noexcept |
Write data to disk - in append mode.
Increment the file size.
[in,out] | file | File handle. |
[in] | file_buffer | Write the buffer contents to disk. |
Cache a row for batch inserts.
Currently used by spatial indexes.
[in,out] | row | Row to add. |
[in] | thread_id | ID of current thread. |
|
noexcept |
Insert cached rows.
[in] | thread_id | Insert cached rows for this thread ID. |
[in,out] | latch_release | Called when a log free check is required. |
|
noexcept |
Note that the latches are going to be released.
Do a deep copy of the tuples that are being inserted in batches by batch_insert
[in] | thread_id | Deep copy cached rows for this thread ID. |
|
noexcept |
Load the sorted data into the B+Tree.
|
privatenoexcept |
Add a row to the merge buffer.
[in,out] | cursor | Current scan cursor. |
[in,out] | row | Row to add. |
[in] | thread_id | ID of current thread. |
[in,out] | latch_release | Called when a log free check is required. |
|
privatenoexcept |
Check for duplicates in the first block.
[in] | dupcheck | Files to check for duplicates. |
[in,out] | dup | For collecting duplicate key information. |
|
noexcept |
Check the state of the online build log for the index.
|
inlineprivatenoexcept |
Clear the heap used for virtual columns.
|
staticprivatenoexcept |
Convert the field data from compact to redundant format.
[in] | clust_index | Clustered index being built |
[in] | row_field | Field to copy from |
[out] | field | Field to copy to |
[in] | len | Length of the field data |
[in] | page_size | Compressed BLOB page size |
[in] | is_sdi | true for SDI Indexes |
[in,out] | heap | Memory heap where to allocate data when converting to ROW_FORMAT=REDUNDANT, or nullptr |
|
staticprivatenoexcept |
Copy externally stored columns to the data tuple.
[in] | index | Index dictionary object. |
[in] | mrec | Record containing BLOB pointers, or nullptr to use tuple instead. |
[in] | offsets | Offsets of mrec. |
[in] | page_size | Compressed page size in bytes, or 0 |
[in,out] | tuple | Data tuple. |
[in] | is_sdi | True for SDI Indexes |
[in,out] | heap | Memory heap |
|
privatenoexcept |
Copy the columns to the temporary file buffer.
[in,out] | ctx | Copy context. |
[in,out] | mv_rows_added | Multi value rows added. |
[in,out] | write_doc_id | Buffer for storing the FTS doc ID. |
Copy the FTS columns.
[in,out] | ctx | Copy context. |
[in,out] | field | Field to write to. |
Add a row to the write buffer.
[in,out] | ctx | Copy context. |
[in,out] | mv_rows_added | Number of multi-value rows added. |
|
privatenoexcept |
Create the merge file, if needed.
[in,out] | file | File handle. |
|
privatenoexcept |
Create the tasks to merge Sort the file before we load the file into the Btree index.
|
inlinenoexcept |
|
noexcept |
Copy blobs to the tuple.
[out] | dtuple | Tuple to copy to. |
[in,out] | offsets | Column offsets in the row. |
[in] | mrec | Current row. |
[in,out] | heap | Heap for the allocating tuple memory. |
|
noexcept |
Parallel scan thread spawn failed, release the extra thread states.
|
privatenoexcept |
Flush all dirty pages, apply the row log and write the redo log record.
|
noexcept |
Close temporary files, Flush all dirty pages, apply the row log and write the redo log record.
|
privatenoexcept |
Add the FTS document ID to the destination field.
[in,out] | dst | Field to write to. |
[in] | src | Field to copy meta data from. |
[out] | write_doc_id | Buffer for copying the doc id. |
|
noexcept |
FTS: Sort and insert the rows read.
|
privatenoexcept |
Wait for FTS completion.
[in] | index | Index being built. |
|
inlinenoexcept |
|
inlinenoexcept |
|
privatenoexcept |
Setup the virtual column src column.
[in,out] | ctx | Copy context. |
[in] | ifield | Index field. |
[in] | col | Table column. |
[out] | src_field | Computed value. |
[in,out] | mv_rows_added | Number of multi-value rows added. |
|
inlinenoexcept |
|
inlinenoexcept |
Initialize the cursor.
[in,out] | cursor | Cursor to initialize. |
[in] | n_threads | Number of threads used for reading. |
Sort the buffer in memory and insert directly in the BTree loader, don't write to a temporary file.
[in,out] | cursor | Current scan cursor. |
[in] | thread_id | ID of current thread. |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
privatenoexcept |
Sort the data in the key buffer.
[in] | thread_id | Thread ID of current thread. |
|
noexcept |
Non-FTS: Sort the rows read.
[in] | thread_id | Thread state ID. |
Cleanup DDL after error in online build Note: To be called if DDL must cleanup due to error in online build.
Pages which are buffer-fixed (in Page_load::release) until the next iteration, must be unfixed (with Page_load::latch) before returning the error.
[in] | err | Error hit in online build |
|
inlinenoexcept |
Set the error code.
[in] | err | Error code to set. |
|
noexcept |
Set the next state.
|
inlinenoexcept |
Set the next state.
[in] | state | State to set. |
|
noexcept |
Non-FTS: Sort the rows read.
|
inlinenoexcept |
|
inlinenoexcept |
|
staticnoexcept |
Write an MLOG_INDEX_LOAD record to indicate in the redo-log that redo-logging of individual index pages was disabled, and the flushing of such pages to the data files was completed.
[in] | index | Index on which redo logging was disabled |
|
private |
Cluster index bulk load instance to use, direct insert without a file sort.
|
private |
For collecting duplicate entries (error reporting).
|
private |
Scoped conversion heap.
|
private |
DDL Context.
|
private |
Buffer ID.
|
private |
Index to create (if not FTS index).
|
private |
Loader that owns the instance.
|
private |
Stage per builder.
|
private |
Number of active sort tasks.
|
private |
For tracking duplicates.
|
private |
The index to be built, FTS or non-FTS.
|
private |
Initial phase.
|
private |
Per thread context.
|
private |
Temporary file path.
|
private |
Scoped virtual column heap.