#include <row0pread-histogram.h>
|
static std::uniform_real_distribution< double > | m_distribution |
| Uniform distribution used by the random generator. More...
|
|
◆ Histogram_sampler()
Histogram_sampler::Histogram_sampler |
( |
size_t |
max_threads, |
|
|
int |
sampling_seed, |
|
|
double |
sampling_percentage, |
|
|
enum_sampling_method |
sampling_method |
|
) |
| |
|
explicit |
Constructor.
- Parameters
-
[in] | max_threads | Maximum number of threads to use. |
[in] | sampling_seed | seed to be used for sampling |
[in] | sampling_percentage | percentage of sampling that needs to be done |
[in] | sampling_method | sampling method to be used for sampling |
◆ ~Histogram_sampler()
Histogram_sampler::~Histogram_sampler |
( |
| ) |
|
◆ buffer_end()
void Histogram_sampler::buffer_end |
( |
| ) |
|
End parallel read in case the reader thread is still active and wait for its exit.
This can happen if we're ending sampling prematurely.
◆ buffer_next()
dberr_t Histogram_sampler::buffer_next |
( |
| ) |
|
Buffer next row.
- Returns
- error code
◆ finish_callback()
Each parallel reader thread's end function.
- Parameters
-
[in] | reader_thread_ctx | context information related to the thread |
- Returns
- DB_SUCCESS or error code.
◆ init()
Initialize the sampler context.
- Parameters
-
[in] | trx | Transaction used for parallel read. |
[in] | index | clustered index. |
[in] | prebuilt | prebuilt info |
- Return values
-
◆ is_error_set()
bool Histogram_sampler::is_error_set |
( |
| ) |
const |
|
inlineprivate |
- Returns
- true if in error state.
◆ process_leaf_rec()
Process the record in the leaf page.
This would happen only when the root page is the leaf page and in such a case we process the page regardless of the sampling percentage.
- Parameters
-
[in] | ctx | Parallel read context. |
[in] | prebuilt | Row meta-data cache. |
- Returns
- error code
◆ process_non_leaf_rec()
For each record in a non-leaf block at level 1 (if leaf level is 0) check if the child page needs to be sampled and if so sample all the rows in the child page.
- Parameters
-
[in] | ctx | Parallel read context. |
[in] | prebuilt | Row meta-data cache. |
- Returns
- error code
◆ run()
Start the sampling process.
- Returns
- DB_SUCCESS or error code.
◆ sample_rec()
Convert the row in InnoDB format to MySQL format and store in the buffer for server to use.
- Parameters
-
[in] | ctx | Parallel read context. |
[in] | rec | record that needs to be converted |
[in] | offsets | offsets belonging to the record |
[in] | index | index of the record |
[in] | prebuilt | Row meta-data cache. |
- Returns
- DB_SUCCESS or error code.
◆ set()
void Histogram_sampler::set |
( |
byte * |
buf | ) |
|
|
inline |
Set the buffer.
- Parameters
-
[in] | buf | buffer to be used to store the row converted to MySQL format. |
◆ set_error_state()
void Histogram_sampler::set_error_state |
( |
dberr_t |
err | ) |
|
|
inlineprivate |
Set the error state.
- Parameters
-
[in] | err | Error state to set to. |
◆ signal_end_of_buffering()
void Histogram_sampler::signal_end_of_buffering |
( |
| ) |
|
|
private |
Signal that the buffering of the row is complete.
◆ signal_start_of_buffering()
void Histogram_sampler::signal_start_of_buffering |
( |
| ) |
|
|
private |
Signal that the next row needs to be buffered.
◆ skip()
bool Histogram_sampler::skip |
( |
| ) |
|
Check if the processing of the record needs to be skipped.
In case of record belonging to non-leaf page, we decide if the child page pertaining to the record needs to be skipped. In case of record belonging to leaf page, we read the page regardless.
- Returns
- true if it needs to be skipped, else false.
◆ start_callback()
Each parallel reader thread's init function.
- Parameters
-
[in] | reader_thread_ctx | context information related to the thread |
- Returns
- DB_SUCCESS or error code.
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.
◆ wait_for_end_of_buffering()
void Histogram_sampler::wait_for_end_of_buffering |
( |
| ) |
|
|
private |
Wait till the buffering of the row is complete.
◆ wait_for_start_of_buffering()
void Histogram_sampler::wait_for_start_of_buffering |
( |
| ) |
|
|
private |
Wait till there is a request to buffer the next row.
◆ m_buf
Buffer to store the sampled row which is in the MySQL format.
◆ m_distribution
std::uniform_real_distribution< double > Histogram_sampler::m_distribution |
|
staticprivate |
Uniform distribution used by the random generator.
◆ m_end_buffer_event
Event to notify if the next row has been buffered.
◆ m_err
Error code when the row was buffered.
◆ m_n_sampled
std::atomic_size_t Histogram_sampler::m_n_sampled |
|
private |
◆ m_parallel_reader
◆ m_random_generator
std::mt19937 Histogram_sampler::m_random_generator |
|
private |
Random generator engine used to provide us random uniformly distributed values required to decide if the row in question needs to be sampled or not.
◆ m_sampling_method
Sampling method to be used for sampling.
◆ m_sampling_percentage
double Histogram_sampler::m_sampling_percentage {} |
|
private |
Sampling percentage to be used for sampling.
◆ m_sampling_seed
int Histogram_sampler::m_sampling_seed {} |
|
private |
Sampling seed to be used for sampling.
◆ m_start_buffer_event
os_event_t Histogram_sampler::m_start_buffer_event |
|
private |
Event to notify if the next row needs to be buffered.
The documentation for this class was generated from the following files: