MySQL 9.0.0
Source Code Documentation
ddl_bulk::Loader Class Reference

#include <ddl0bulk.h>

Classes

class  Thread_data
 

Public Types

using Blob_context = void *
 
using byte = unsigned char
 
using Btree_loads = std::vector< Btree_multi::Btree_load *, ut::allocator< Btree_multi::Btree_load * > >
 
using Thread_ctxs = std::vector< Thread_data, ut::allocator< Thread_data > >
 

Public Member Functions

 Loader (size_t num_threads)
 Loader context constructor. More...
 
dberr_t begin (const row_prebuilt_t *prebuilt, size_t data_size, size_t memory)
 Prepare bulk loading by multiple threads. More...
 
dberr_t load (const row_prebuilt_t *prebuilt, size_t thread_index, const Rows_mysql &rows, Bulk_load::Stat_callbacks &wait_cbk)
 Load rows to a sub-tree by a thread. More...
 
dberr_t open_blob (size_t thread_index, Blob_context &blob_ctx, lob::ref_t &ref)
 Open a blob. More...
 
dberr_t write_blob (size_t thread_index, Blob_context blob_ctx, lob::ref_t &ref, const byte *data, size_t len)
 Write data into the blob. More...
 
dberr_t close_blob (size_t thread_index, 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...
 
dberr_t end (const row_prebuilt_t *prebuilt, bool is_error)
 Finish bulk load operation, combining the sub-trees produced by concurrent threads. More...
 
dberr_t get_error () const
 
std::string get_error_string () const
 
int get_error_code () const
 Get the client error code (e.g. More...
 
const char * get_table_name () const
 
const char * get_index_name () const
 

Private Member Functions

dberr_t merge_subtrees (const row_prebuilt_t *prebuilt)
 Merge the sub-trees to build the cluster index. More...
 
void get_queue_size (size_t memory, size_t &flush_queue_size, bool &allocate_in_pages) const
 Calculate the flush queue size to be used based on the available memory. More...
 

Private Attributes

size_t m_num_threads {}
 Number of threads for bulk loading. More...
 
Thread_ctxs m_ctxs
 All thread specific data. More...
 
Btree_loads m_sub_tree_loads
 Sub-tree loading contexts. More...
 
dict_table_tm_table
 Innodb dictionary table object. More...
 
Btree_multi::Bulk_extent_allocator m_extent_allocator
 Allocator to extend tablespace and allocate extents. More...
 

Member Typedef Documentation

◆ Blob_context

◆ Btree_loads

◆ byte

using ddl_bulk::Loader::byte = unsigned char

◆ Thread_ctxs

Constructor & Destructor Documentation

◆ Loader()

ddl_bulk::Loader::Loader ( size_t  num_threads)
inline

Loader context constructor.

Parameters
[in]num_threadsNumber of threads to use for bulk loading

Member Function Documentation

◆ begin()

dberr_t Loader::begin ( const row_prebuilt_t prebuilt,
size_t  data_size,
size_t  memory 
)

Prepare bulk loading by multiple threads.

Parameters
[in]prebuiltprebuilt structures from innodb table handler
[in]data_sizetotal data size to load in bytes
[in]memorymemory to be used from buffer pool
Returns
innodb error code

◆ close_blob()

dberr_t Loader::close_blob ( size_t  thread_index,
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.

Parameters
[in]thread_indexidentifies the thread and the B-tree to use.
[in]blob_ctxpointer to blob which has been completely written.
[out]refblob reference to be placed in the record.
Returns
DB_SUCCESS on success or a failure error code.

◆ end()

dberr_t Loader::end ( const row_prebuilt_t prebuilt,
bool  is_error 
)

Finish bulk load operation, combining the sub-trees produced by concurrent threads.

Parameters
[in]prebuiltprebuilt structures from innodb table handler
[in]is_errortrue if called for cleanup and rollback after an error
Returns
innodb error code

◆ get_error()

dberr_t Loader::get_error ( ) const
inline

◆ get_error_code()

int Loader::get_error_code ( ) const
inline

Get the client error code (e.g.

ER_LOAD_BULK_DATA_UNSORTED).

Returns
the client error code.

◆ get_error_string()

std::string Loader::get_error_string ( ) const
inline

◆ get_index_name()

const char * ddl_bulk::Loader::get_index_name ( ) const
inline
Returns
index name where the data is being loaded.

◆ get_queue_size()

void Loader::get_queue_size ( size_t  memory,
size_t &  flush_queue_size,
bool &  allocate_in_pages 
) const
private

Calculate the flush queue size to be used based on the available memory.

Parameters
[in]memorytotal buffer pool memory to use
[out]flush_queue_sizecalculated queue size
[out]allocate_in_pagestrue if need to allocate in pages false if need to allocate in extents

◆ get_table_name()

const char * ddl_bulk::Loader::get_table_name ( ) const
inline
Returns
table name where the data is being loaded.

◆ load()

dberr_t Loader::load ( const row_prebuilt_t prebuilt,
size_t  thread_index,
const Rows_mysql rows,
Bulk_load::Stat_callbacks wait_cbk 
)

Load rows to a sub-tree by a thread.

Called concurrently by multiple execution threads.

Parameters
[in]prebuiltprebuilt structures from innodb table handler
[in]thread_indexidentifies the thread and the B-tree to use.
[in]rowsrows to be loaded to the cluster index sub-tree
[in]wait_cbkStat callbacks
Returns
innodb error code

◆ merge_subtrees()

dberr_t Loader::merge_subtrees ( const row_prebuilt_t prebuilt)
private

Merge the sub-trees to build the cluster index.

Parameters
[in]prebuiltprebuilt structures from innodb table handler
Returns
innodb error code.

◆ open_blob()

dberr_t Loader::open_blob ( size_t  thread_index,
Blob_context blob_ctx,
lob::ref_t ref 
)

Open a blob.

Parameters
[in]thread_indexidentifies the thread and the B-tree to use.
[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.

◆ write_blob()

dberr_t Loader::write_blob ( size_t  thread_index,
Blob_context  blob_ctx,
lob::ref_t ref,
const byte data,
size_t  len 
)

Write data into the blob.

Parameters
[in]thread_indexidentifies the thread and the B-tree to use.
[in]blob_ctxpointer to blob into which data is written.
[out]refblob reference to be placed in the record.
[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.

Member Data Documentation

◆ m_ctxs

Thread_ctxs ddl_bulk::Loader::m_ctxs
private

All thread specific data.

◆ m_extent_allocator

Btree_multi::Bulk_extent_allocator ddl_bulk::Loader::m_extent_allocator
private

Allocator to extend tablespace and allocate extents.

◆ m_num_threads

size_t ddl_bulk::Loader::m_num_threads {}
private

Number of threads for bulk loading.

◆ m_sub_tree_loads

Btree_loads ddl_bulk::Loader::m_sub_tree_loads
private

Sub-tree loading contexts.

◆ m_table

dict_table_t* ddl_bulk::Loader::m_table
private

Innodb dictionary table object.


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