![]() |
MySQL 8.0.43
Source Code Documentation
|
This class represents a buffer that can be used for multi-row reads. More...
#include <record_buffer.h>
Public Member Functions | |
| Record_buffer (ha_rows records, size_t record_size, uchar *buffer) | |
| Create a new record buffer with the specified size. More... | |
| ha_rows | max_records () const |
| Get the number of records that can be stored in the buffer. More... | |
| size_t | record_size () const |
| Get the amount of space allocated for each record in the buffer. More... | |
| ha_rows | records () const |
| Get the number of records currently stored in the buffer. More... | |
| uchar * | record (ha_rows pos) const |
| Get the buffer that holds the record on position pos. More... | |
| uchar * | add_record () |
| Add a new record at the end of the buffer. More... | |
| void | remove_last () |
| Remove the record that was last added to the buffer. More... | |
| void | clear () |
| Clear the buffer. More... | |
| void | reset () |
| Reset the buffer. More... | |
| void | set_out_of_range (bool val) |
| Set whether the end of the range was reached while filling the buffer. More... | |
| bool | is_out_of_range () const |
| Check if the end of the range was reached while filling the buffer. More... | |
Static Public Member Functions | |
| static constexpr size_t | buffer_size (ha_rows records, size_t record_size) |
This function calculates how big the uchar buffer provided to Record_buffer's constructor must be, given a number of records and the record size. More... | |
Private Attributes | |
| ha_rows | m_max_records |
| The maximum number of records that can be stored in the buffer. More... | |
| size_t | m_record_size |
| The number of bytes available for each record. More... | |
| ha_rows | m_count = 0 |
| The number of records currently stored in the buffer. More... | |
| uchar * | m_buffer |
The uchar buffer that holds the records. More... | |
| bool | m_out_of_range = false |
| Tells if end-of-range was found while filling the buffer. More... | |
This class represents a buffer that can be used for multi-row reads.
It is allocated by the executor and given to the storage engine through the handler, using handler::ha_set_record_buffer(), so that the storage engine can fill the buffer with multiple rows in a single read call.
For now, the record buffer is only used internally by the storage engine as a prefetch cache. The storage engine fills the record buffer when the executor requests the first record, but it returns a single record only to the executor. If the executor wants to access the records in the buffer, it has to call a handler function such as handler::ha_index_next() or handler::ha_rnd_next(). Then the storage engine will copy the next record from the record buffer to the memory area specified in the arguments of the handler function, typically TABLE::record[0].
Create a new record buffer with the specified size.
| records | the number of records that can be stored in the buffer |
| record_size | the size of each record |
| buffer | the uchar buffer that will hold the records (its size should be at least Record_buffer::buffer_size(records, record_size)) |
|
inline |
Add a new record at the end of the buffer.
uchar buffer of the added record
|
inlinestaticconstexpr |
This function calculates how big the uchar buffer provided to Record_buffer's constructor must be, given a number of records and the record size.
| records | the maximum number of records in the buffer |
| record_size | the size of each record |
|
inline |
Clear the buffer.
Remove all the records. The end-of-range flag is preserved.
|
inline |
Check if the end of the range was reached while filling the buffer.
| true | if the end range was reached |
| false | if the scan is still within the range |
|
inline |
Get the number of records that can be stored in the buffer.
Get the buffer that holds the record on position pos.
| pos | the record number (must be smaller than records()) |
uchar buffer that holds the specified record
|
inline |
Get the amount of space allocated for each record in the buffer.
|
inline |
Get the number of records currently stored in the buffer.
|
inline |
Remove the record that was last added to the buffer.
|
inline |
Reset the buffer.
Remove all records and clear the end-of-range flag.
|
inline |
Set whether the end of the range was reached while filling the buffer.
| val | true if end of range was reached, false if still within range |
|
private |
The uchar buffer that holds the records.
|
private |
The number of records currently stored in the buffer.
|
private |
The maximum number of records that can be stored in the buffer.
|
private |
Tells if end-of-range was found while filling the buffer.
|
private |
The number of bytes available for each record.