MySQL 9.1.0
Source Code Documentation
|
Parallel reader context. More...
#include <row0pread.h>
Classes | |
struct | Iter |
Boundary of the range to scan. More... | |
Public Member Functions | |
Scan_ctx (Parallel_reader *reader, size_t id, trx_t *trx, const Parallel_reader::Config &config, F &&f) | |
Constructor. More... | |
~Scan_ctx ()=default | |
Destructor. More... | |
Private Types | |
using | Savepoint = std::pair< ulint, buf_block_t * > |
mtr_t savepoint. More... | |
using | Savepoints = std::vector< Savepoint, ut::allocator< Savepoint > > |
For releasing the S latches after processing the blocks. More... | |
using | Range = std::pair< std::shared_ptr< Iter >, std::shared_ptr< Iter > > |
The first cursor should read up to the second cursor [f, s). More... | |
using | Ranges = std::vector< Range, ut::allocator< Range > > |
using | Config = Parallel_reader::Config |
Private Member Functions | |
size_t | id () const |
void | set_error_state (dberr_t err) |
Set the error state. More... | |
bool | is_error_set () const |
buf_block_t * | block_get_s_latched (const page_id_t &page_id, mtr_t *mtr, size_t line) const |
Fetch a block from the buffer pool and acquire an S latch on it. More... | |
dberr_t | partition (const Scan_range &scan_range, Ranges &ranges, size_t split_level) |
Partition the B+Tree for parallel read. More... | |
page_no_t | search (const buf_block_t *block, const dtuple_t *key) const |
Find the page number of the node that contains the search key. More... | |
page_cur_t | start_range (page_no_t page_no, mtr_t *mtr, const dtuple_t *key, Savepoints &savepoints) const |
Traverse from given sub-tree page number to start of the scan range from the given page number. More... | |
void | create_range (Ranges &ranges, page_cur_t &leaf_page_cursor, mtr_t *mtr) const |
Create and add the range to the scan ranges. More... | |
dberr_t | create_ranges (const Scan_range &scan_range, page_no_t page_no, size_t depth, const size_t split_level, Ranges &ranges, mtr_t *mtr) |
Find the subtrees to scan in a block. More... | |
void | copy_row (const rec_t *rec, Iter *iter) const |
Build a dtuple_t from rec_t. More... | |
std::shared_ptr< Iter > | create_persistent_cursor (const page_cur_t &page_cursor, mtr_t *mtr) const |
Create the persistent cursor that will be used to traverse the partition and position on the the start row. More... | |
bool | check_visibility (const rec_t *&rec, ulint *&offsets, mem_heap_t *&heap, mtr_t *mtr) |
Build an old version of the row if required. More... | |
dberr_t | create_context (const Range &range, bool split) |
Create an execution context for a range and add it to the Parallel_reader's run queue. More... | |
dberr_t | create_contexts (const Ranges &ranges) |
Create the execution contexts based on the ranges. More... | |
size_t | max_threads () const |
void | release_threads (size_t unused_threads) |
Release unused threads back to the pool. More... | |
void | index_s_lock () |
S lock the index. More... | |
void | index_s_unlock () |
S unlock the index. More... | |
bool | index_s_own () const |
Scan_ctx (Scan_ctx &&)=delete | |
Scan_ctx (const Scan_ctx &)=delete | |
Scan_ctx & | operator= (Scan_ctx &&)=delete |
Scan_ctx & | operator= (const Scan_ctx &)=delete |
Private Attributes | |
size_t | m_id {std::numeric_limits<size_t>::max()} |
Context ID. More... | |
Config | m_config |
Parallel scan configuration. More... | |
const trx_t * | m_trx {} |
Covering transaction. More... | |
F | m_f |
Callback function. More... | |
size_t | m_depth {} |
Depth of the Btree. More... | |
Parallel_reader * | m_reader {} |
The parallel reader. More... | |
std::atomic< dberr_t > | m_err {DB_SUCCESS} |
Error during parallel read. More... | |
std::atomic_size_t | m_s_locks {} |
Number of threads that have S locked the index. More... | |
Friends | |
class | Parallel_reader |
Parallel reader context.
|
private |
|
private |
The first cursor should read up to the second cursor [f, s).
|
private |
|
private |
mtr_t savepoint.
|
private |
For releasing the S latches after processing the blocks.
Parallel_reader::Scan_ctx::Scan_ctx | ( | Parallel_reader * | reader, |
size_t | id, | ||
trx_t * | trx, | ||
const Parallel_reader::Config & | config, | ||
F && | f | ||
) |
Constructor.
[in] | reader | Parallel reader that owns this context. |
[in] | id | ID of this scan context. |
[in] | trx | Transaction covering the scan. |
[in] | config | Range scan config. |
[in] | f | Callback function. |
|
default |
Destructor.
|
privatedelete |
|
privatedelete |
|
private |
Fetch a block from the buffer pool and acquire an S latch on it.
[in] | page_id | Page ID. |
[in,out] | mtr | Mini-transaction covering the fetch. |
[in] | line | Line from where called. |
|
private |
Build an old version of the row if required.
[in,out] | rec | Current row read from the index. This can be modified by this method if an older version needs to be built. |
[in,out] | offsets | Same as above but pertains to the rec offsets |
[in,out] | heap | Heap to use if a previous version needs to be built from the undo log. |
[in,out] | mtr | Mini-transaction covering the read. |
Build a dtuple_t from rec_t.
[in] | rec | Build the dtuple from this record. |
[in,out] | iter | Build in this iterator. |
Create an execution context for a range and add it to the Parallel_reader's run queue.
[in] | range | Range for which to create the context. |
[in] | split | true if the sub-tree should be split further. |
Create the execution contexts based on the ranges.
[in] | ranges | Ranges for which to create the contexts. |
|
private |
Create the persistent cursor that will be used to traverse the partition and position on the the start row.
[in] | page_cursor | Current page cursor |
[in] | mtr | Mini-transaction covering the read. |
|
private |
Create and add the range to the scan ranges.
[in,out] | ranges | Ranges to scan. |
[in,out] | leaf_page_cursor | Leaf page cursor on which to create the persistent cursor. |
[in,out] | mtr | Mini-transaction |
|
private |
Find the subtrees to scan in a block.
[in] | scan_range | Partition based on this scan range. |
[in] | page_no | Page to partition at if at required level. |
[in] | depth | Sub-range current level. |
[in] | split_level | Sub-range starting level (0 == root). |
[in,out] | ranges | Ranges to scan. |
[in,out] | mtr | Mini-transaction |
|
inlineprivate |
|
private |
S lock the index.
|
inlineprivate |
|
private |
S unlock the index.
|
inlineprivate |
|
inlineprivate |
|
private |
Partition the B+Tree for parallel read.
[in] | scan_range | Range for partitioning. |
[in,out] | ranges | Ranges to scan. |
[in] | split_level | Sub-range required level (0 == root). |
|
inlineprivate |
Release unused threads back to the pool.
[in] | unused_threads | Number of threads to "release". |
|
private |
Find the page number of the node that contains the search key.
If the key is null then we assume -infinity.
[in] | block | Page to look in. |
[in] | key | Key of the first record in the range. |
|
inlineprivate |
Set the error state.
[in] | err | Error state to set to. |
|
private |
Traverse from given sub-tree page number to start of the scan range from the given page number.
[in] | page_no | Page number of sub-tree. |
[in,out] | mtr | Mini-transaction. |
[in] | key | Key of the first record in the range. |
[in,out] | savepoints | Blocks S latched and accessed. |
|
friend |
|
private |
Parallel scan configuration.
|
private |
Depth of the Btree.
|
mutableprivate |
Error during parallel read.
|
private |
Callback function.
|
private |
Context ID.
|
private |
The parallel reader.
|
private |
Number of threads that have S locked the index.
|
private |
Covering transaction.