MySQL  8.0.21
Source Code Documentation
Record_buffer Class Reference

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...
 
ucharrecord (ha_rows pos) const
 Get the buffer that holds the record on position pos. More...
 
ucharadd_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...
 
ucharm_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...
 

Detailed Description

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].

Constructor & Destructor Documentation

◆ Record_buffer()

Record_buffer::Record_buffer ( ha_rows  records,
size_t  record_size,
uchar buffer 
)
inline

Create a new record buffer with the specified size.

Parameters
recordsthe number of records that can be stored in the buffer
record_sizethe size of each record
bufferthe uchar buffer that will hold the records (its size should be at least Record_buffer::buffer_size(records, record_size))

Member Function Documentation

◆ add_record()

uchar* Record_buffer::add_record ( )
inline

Add a new record at the end of the buffer.

Returns
the uchar buffer of the added record

◆ buffer_size()

static constexpr size_t Record_buffer::buffer_size ( ha_rows  records,
size_t  record_size 
)
inlinestatic

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.

Parameters
recordsthe maximum number of records in the buffer
record_sizethe size of each record
Returns
the total number of bytes needed for all the records

◆ clear()

void Record_buffer::clear ( )
inline

Clear the buffer.

Remove all the records. The end-of-range flag is preserved.

◆ is_out_of_range()

bool Record_buffer::is_out_of_range ( ) const
inline

Check if the end of the range was reached while filling the buffer.

Return values
trueif the end range was reached
falseif the scan is still within the range

◆ max_records()

ha_rows Record_buffer::max_records ( ) const
inline

Get the number of records that can be stored in the buffer.

Returns
the maximum number of records in the buffer

◆ record()

uchar* Record_buffer::record ( ha_rows  pos) const
inline

Get the buffer that holds the record on position pos.

Parameters
posthe record number (must be smaller than records())
Returns
the uchar buffer that holds the specified record

◆ record_size()

size_t Record_buffer::record_size ( ) const
inline

Get the amount of space allocated for each record in the buffer.

Returns
the record size

◆ records()

ha_rows Record_buffer::records ( ) const
inline

Get the number of records currently stored in the buffer.

Returns
the number of records stored in the buffer

◆ remove_last()

void Record_buffer::remove_last ( )
inline

Remove the record that was last added to the buffer.

◆ reset()

void Record_buffer::reset ( void  )
inline

Reset the buffer.

Remove all records and clear the end-of-range flag.

◆ set_out_of_range()

void Record_buffer::set_out_of_range ( bool  val)
inline

Set whether the end of the range was reached while filling the buffer.

Parameters
valtrue if end of range was reached, false if still within range

Member Data Documentation

◆ m_buffer

uchar* Record_buffer::m_buffer
private

The uchar buffer that holds the records.

◆ m_count

ha_rows Record_buffer::m_count = 0
private

The number of records currently stored in the buffer.

◆ m_max_records

ha_rows Record_buffer::m_max_records
private

The maximum number of records that can be stored in the buffer.

◆ m_out_of_range

bool Record_buffer::m_out_of_range = false
private

Tells if end-of-range was found while filling the buffer.

◆ m_record_size

size_t Record_buffer::m_record_size
private

The number of bytes available for each record.


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