MySQL 9.1.0
Source Code Documentation
|
Traverse an index in the leaf page block list order and send records to adapter. More...
#include <row0pread-adapter.h>
Classes | |
struct | MySQL_row |
MySQL row meta data. More... | |
struct | Thread_ctx |
Callback thread context for each of the spawned threads. More... | |
Public Types | |
using | Load_fn = handler::Load_cbk |
using | End_fn = handler::Load_end_cbk |
using | Init_fn = handler::Load_init_cbk |
Public Member Functions | |
Parallel_reader_adapter (size_t max_threads, ulint rowlen) | |
Constructor. More... | |
~Parallel_reader_adapter ()=default | |
Destructor. More... | |
dberr_t | add_scan (trx_t *trx, const Parallel_reader::Config &config, Parallel_reader::F &&f) |
Add scan context. More... | |
dberr_t | run (void **thread_contexts, Init_fn init_fn, Load_fn load_fn, End_fn end_fn) |
Run the parallel scan. More... | |
dberr_t | process_rows (const Parallel_reader::Ctx *reader_ctx) |
Convert the record in InnoDB format to MySQL format and send them. More... | |
void | set (row_prebuilt_t *prebuilt) |
Set up the query processing state cache. More... | |
Private Member Functions | |
dberr_t | init (Parallel_reader::Thread_ctx *reader_thread_ctx, row_prebuilt_t *prebuilt) |
Each parallel reader thread's init function. More... | |
dberr_t | end (Parallel_reader::Thread_ctx *reader_thread_ctx) |
Each parallel reader thread's end function. More... | |
dberr_t | send_batch (Parallel_reader::Thread_ctx *reader_thread_ctx, size_t partition_id, uint64_t n_recs) |
Send a batch of records. More... | |
size_t | pending (Thread_ctx *ctx) const |
Get the number of rows buffered but not sent. More... | |
bool | is_buffer_full (Thread_ctx *ctx) const |
Check if the buffer is full. More... | |
Private Attributes | |
void ** | m_thread_ctxs {} |
Adapter context for each of the spawned threads. More... | |
Init_fn | m_init_fn {} |
Callback called by each parallel load thread at the beginning of the parallel load for the scan. More... | |
Load_fn | m_load_fn {} |
Callback called by each parallel load thread when processing of rows is required for the scan. More... | |
End_fn | m_end_fn {} |
Callback called by each parallel load thread when processing of rows has ended for the scan. More... | |
uint64_t | m_batch_size {} |
Number of records to be sent across to the caller in a batch. More... | |
MySQL_row | m_mysql_row {} |
Row meta data per scan context. More... | |
row_prebuilt_t * | m_prebuilt {} |
Prebuilt to use for conversion to MySQL row format. More... | |
Parallel_reader | m_parallel_reader |
Parallel reader to use. More... | |
Static Private Attributes | |
static constexpr size_t | ADAPTER_SEND_BUFFER_SIZE = 2 * 1024 * 1024 |
Size of the buffer used to store InnoDB records and sent to the adapter. More... | |
Traverse an index in the leaf page block list order and send records to adapter.
Parallel_reader_adapter::Parallel_reader_adapter | ( | size_t | max_threads, |
ulint | rowlen | ||
) |
Constructor.
[in] | max_threads | Maximum threads to use for all scan contexts. |
[in] | rowlen | Row length. |
|
default |
Destructor.
dberr_t Parallel_reader_adapter::add_scan | ( | trx_t * | trx, |
const Parallel_reader::Config & | config, | ||
Parallel_reader::F && | f | ||
) |
Add scan context.
[in] | trx | Transaction used for parallel read. |
[in] | config | (Cluster) Index scan configuration. |
[in] | f | Callback function. |
|
private |
Each parallel reader thread's end function.
[in] | reader_thread_ctx | context info related to the current thread |
|
private |
Each parallel reader thread's init function.
[in] | reader_thread_ctx | context info related to the current thread |
[in] | prebuilt | prebuilt cache |
There are data members in row_prebuilt_t that cannot be accessed in multi-threaded mode e.g., blob_heap.
row_prebuilt_t is designed for single threaded access and to share it among threads is not recommended unless "you know what you are doing". This is very fragile code as it stands.
To solve the blob heap issue in prebuilt we request parallel reader thread to use blob heap per thread and we pass this blob heap to the InnoDB to MySQL row format conversion function.
|
inlineprivate |
Check if the buffer is full.
[in] | ctx | adapter related thread context information. |
|
inlineprivate |
Get the number of rows buffered but not sent.
[in] | ctx | adapter related thread context information. |
dberr_t Parallel_reader_adapter::process_rows | ( | const Parallel_reader::Ctx * | reader_ctx | ) |
Convert the record in InnoDB format to MySQL format and send them.
[in] | reader_ctx | Parallel read context. |
dberr_t Parallel_reader_adapter::run | ( | void ** | thread_contexts, |
Init_fn | init_fn, | ||
Load_fn | load_fn, | ||
End_fn | end_fn | ||
) |
Run the parallel scan.
[in] | thread_contexts | Context for each of the spawned threads |
[in] | init_fn | Callback called by each parallel load thread at the beginning of the parallel load. |
[in] | load_fn | Callback called by each parallel load thread when processing of rows is required. |
[in] | end_fn | Callback called by each parallel load thread when processing of rows has ended. |
|
private |
Send a batch of records.
[in] | reader_thread_ctx | reader threads related thread context info |
[in] | partition_id | partition ID of the index the record belongs to |
[in] | n_recs | Number of records to send. |
void Parallel_reader_adapter::set | ( | row_prebuilt_t * | prebuilt | ) |
Set up the query processing state cache.
[in] | prebuilt | The prebuilt cache for the query. |
|
staticconstexprprivate |
Size of the buffer used to store InnoDB records and sent to the adapter.
|
private |
Number of records to be sent across to the caller in a batch.
|
private |
Callback called by each parallel load thread when processing of rows has ended for the scan.
|
private |
Callback called by each parallel load thread at the beginning of the parallel load for the scan.
|
private |
Callback called by each parallel load thread when processing of rows is required for the scan.
|
private |
Row meta data per scan context.
|
private |
Parallel reader to use.
|
private |
Prebuilt to use for conversion to MySQL row format.
NOTE: We are sharing this because we don't convert BLOBs yet. There are data members in row_prebuilt_t that cannot be accessed in multi-threaded mode e.g., blob_heap.
row_prebuilt_t is designed for single threaded access and to share it among threads is not recommended unless "you know what you are doing". This is very fragile code as it stands.
To solve the blob heap issue in prebuilt we use per thread m_blob_heaps. Pass the blob heap to the InnoDB to MySQL row format conversion function.
|
private |
Adapter context for each of the spawned threads.
We don't know the type of the context it's passed to us as a void *.