MySQL  8.0.27
Source Code Documentation
MultiRangeRowIterator Class Referencefinal

The iterator actually doing the reads from the inner table during BKA. More...

#include <bka_iterator.h>

Inheritance diagram for MultiRangeRowIterator:
TableRowIterator RowIterator

Public Member Functions

 MultiRangeRowIterator (THD *thd, TABLE *table, TABLE_REF *ref, int mrr_flags, JoinType join_type, const Prealloced_array< TABLE *, 4 > &outer_input_tables, bool store_rowids, table_map tables_to_get_rowid_for)
 
void set_rows (const hash_join_buffer::BufferRow *begin, const hash_join_buffer::BufferRow *end)
 Specify which outer rows to read inner rows for. More...
 
void set_mrr_buffer (uchar *ptr, size_t size)
 Specify an unused chunk of memory MRR can use for the returned inner rows. More...
 
void set_match_flag_buffer (uchar *ptr)
 Specify an unused chunk of memory that we can use to mark which inner rows have been read (by the parent BKA iterator) or not. More...
 
void MarkLastRowAsRead ()
 Mark that the BKA iterator has seen the last row we returned from Read(). More...
 
bool RowHasBeenRead (const hash_join_buffer::BufferRow *row) const
 Check whether the given row has been marked as read (using MarkLastRowAsRead()) or not. More...
 
bool Init () override
 Do the actual multi-range read with the rows given by set_rows() and using the temporary buffer given in set_mrr_buffer(). More...
 
int Read () override
 Read another inner row (if any) and load the appropriate outer row(s) into the associated table buffers. More...
 
- Public Member Functions inherited from TableRowIterator
 TableRowIterator (THD *thd, TABLE *table)
 
void UnlockRow () override
 The default implementation of unlock-row method of RowIterator, used in all access methods except EQRefIterator. More...
 
void SetNullRowFlag (bool is_null_row) override
 Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag is true, you'll get only NULLs no matter what is actually in the buffer (typically some old leftover row). More...
 
void StartPSIBatchMode () override
 Start performance schema batch mode, if supported (otherwise ignored). More...
 
void EndPSIBatchModeIfStarted () override
 Ends performance schema batch mode, if started. More...
 
- Public Member Functions inherited from RowIterator
 RowIterator (THD *thd)
 
virtual ~RowIterator ()=default
 
virtual std::string TimingString () const
 
virtual RowIteratorreal_iterator ()
 If this iterator is wrapping a different iterator (e.g. More...
 
virtual const RowIteratorreal_iterator () const
 

Private Member Functions

range_seq_t MrrInitCallback (uint n_ranges, uint flags)
 
uint MrrNextCallback (KEY_MULTI_RANGE *range)
 
bool MrrSkipIndexTuple (char *range_info)
 
bool MrrSkipRecord (char *range_info)
 

Static Private Member Functions

static range_seq_t MrrInitCallbackThunk (void *init_params, uint n_ranges, uint flags)
 
static uint MrrNextCallbackThunk (void *init_params, KEY_MULTI_RANGE *range)
 
static bool MrrSkipRecordCallbackThunk (range_seq_t seq, char *range_info, uchar *)
 

Private Attributes

handler *const m_file
 Handler for the table we are reading from. More...
 
TABLE_REF *const m_ref
 The index condition. More...
 
const int m_mrr_flags
 Flags passed on to MRR. More...
 
const hash_join_buffer::BufferRowm_begin
 Current outer rows to read inner rows for. Set by set_rows(). More...
 
const hash_join_buffer::BufferRowm_end
 
const hash_join_buffer::BufferRowm_current_pos
 Which row we are at in the [m_begin, m_end) range. More...
 
const hash_join_buffer::BufferRowm_last_row_returned
 What row we last returned from Read() (used for MarkLastRowAsRead()). More...
 
HANDLER_BUFFER m_mrr_buffer
 Temporary space for storing inner rows, used by MRR. More...
 
ucharm_match_flag_buffer = nullptr
 See set_match_flag_buffer(). More...
 
pack_rows::TableCollection m_outer_input_tables
 Tables and columns needed for each outer row. More...
 
const JoinType m_join_type
 The join type of the BKA join we are part of. More...
 

Additional Inherited Members

- Protected Member Functions inherited from TableRowIterator
int HandleError (int error)
 
void PrintError (int error)
 
TABLEtable () const
 
- Protected Member Functions inherited from RowIterator
THDthd () const
 

Detailed Description

The iterator actually doing the reads from the inner table during BKA.

See file comment.

Constructor & Destructor Documentation

◆ MultiRangeRowIterator()

MultiRangeRowIterator::MultiRangeRowIterator ( THD thd,
TABLE table,
TABLE_REF ref,
int  mrr_flags,
JoinType  join_type,
const Prealloced_array< TABLE *, 4 > &  outer_input_tables,
bool  store_rowids,
table_map  tables_to_get_rowid_for 
)
Parameters
thdThread handle.
tableThe inner table to scan.
refThe index condition we are looking up on.
mrr_flagsFlags passed on to MRR.
join_typeWhat kind of BKA join this MRR iterator is part of.
outer_input_tablesWhich tables are on the left side of the BKA join (the MRR iterator is always alone on the right side). This is needed so that it can unpack the rows into the right tables, with the right format.
store_rowidsWhether we need to keep row IDs.
tables_to_get_rowid_forTables we need to call table->file->position() for; if a table is present in outer_input_tables but not this, some other iterator will make sure that table has the correct row ID already present after Read().

Member Function Documentation

◆ Init()

bool MultiRangeRowIterator::Init ( )
overridevirtual

Do the actual multi-range read with the rows given by set_rows() and using the temporary buffer given in set_mrr_buffer().

We don't send a set of rows directly to MRR; instead, we give it a set of function pointers to iterate over the rows, and a pointer to ourselves. The handler will call our callbacks as follows:

  1. MrrInitCallback at the start, to initialize iteration.
  2. MrrNextCallback is called to yield ranges to scan, until it returns 1.

Implements RowIterator.

◆ MarkLastRowAsRead()

void MultiRangeRowIterator::MarkLastRowAsRead ( )
inline

Mark that the BKA iterator has seen the last row we returned from Read().

(It could have been discarded by a FilterIterator before it reached them.) Will be a no-op for inner joins; see set_match_flag_buffer()..

◆ MrrInitCallback()

range_seq_t MultiRangeRowIterator::MrrInitCallback ( uint  n_ranges,
uint  flags 
)
private

◆ MrrInitCallbackThunk()

static range_seq_t MultiRangeRowIterator::MrrInitCallbackThunk ( void *  init_params,
uint  n_ranges,
uint  flags 
)
inlinestaticprivate

◆ MrrNextCallback()

uint MultiRangeRowIterator::MrrNextCallback ( KEY_MULTI_RANGE range)
private

◆ MrrNextCallbackThunk()

static uint MultiRangeRowIterator::MrrNextCallbackThunk ( void *  init_params,
KEY_MULTI_RANGE range 
)
inlinestaticprivate

◆ MrrSkipIndexTuple()

bool MultiRangeRowIterator::MrrSkipIndexTuple ( char *  range_info)
private

◆ MrrSkipRecord()

bool MultiRangeRowIterator::MrrSkipRecord ( char *  range_info)
private

◆ MrrSkipRecordCallbackThunk()

static bool MultiRangeRowIterator::MrrSkipRecordCallbackThunk ( range_seq_t  seq,
char *  range_info,
uchar  
)
inlinestaticprivate

◆ Read()

int MultiRangeRowIterator::Read ( )
overridevirtual

Read another inner row (if any) and load the appropriate outer row(s) into the associated table buffers.

Implements RowIterator.

◆ RowHasBeenRead()

bool MultiRangeRowIterator::RowHasBeenRead ( const hash_join_buffer::BufferRow row) const
inline

Check whether the given row has been marked as read (using MarkLastRowAsRead()) or not.

Used internally when doing semijoins, and also by the BKAIterator when synthesizing NULL-complemented rows for outer joins or antijoins.

◆ set_match_flag_buffer()

void MultiRangeRowIterator::set_match_flag_buffer ( uchar ptr)
inline

Specify an unused chunk of memory that we can use to mark which inner rows have been read (by the parent BKA iterator) or not.

This is used for outer joins to know which rows need NULL-complemented versions, and for semijoins and antijoins to avoid matching the same inner row more than once.

Must be called before Init() for semijoins, outer joins and antijoins, and never called otherwise. There must be room at least for one bit per row given in set_rows().

◆ set_mrr_buffer()

void MultiRangeRowIterator::set_mrr_buffer ( uchar ptr,
size_t  size 
)
inline

Specify an unused chunk of memory MRR can use for the returned inner rows.

Must be called before Init(), and must be at least big enough to hold one inner row.

◆ set_rows()

void MultiRangeRowIterator::set_rows ( const hash_join_buffer::BufferRow begin,
const hash_join_buffer::BufferRow end 
)
inline

Specify which outer rows to read inner rows for.

Must be called before Init(), and be valid until the last Read().

Member Data Documentation

◆ m_begin

const hash_join_buffer::BufferRow* MultiRangeRowIterator::m_begin
private

Current outer rows to read inner rows for. Set by set_rows().

◆ m_current_pos

const hash_join_buffer::BufferRow* MultiRangeRowIterator::m_current_pos
private

Which row we are at in the [m_begin, m_end) range.

Used during the MRR callbacks.

◆ m_end

const hash_join_buffer::BufferRow* MultiRangeRowIterator::m_end
private

◆ m_file

handler* const MultiRangeRowIterator::m_file
private

Handler for the table we are reading from.

◆ m_join_type

const JoinType MultiRangeRowIterator::m_join_type
private

The join type of the BKA join we are part of.

Same as m_join_type in the corresponding BKAIterator.

◆ m_last_row_returned

const hash_join_buffer::BufferRow* MultiRangeRowIterator::m_last_row_returned
private

What row we last returned from Read() (used for MarkLastRowAsRead()).

◆ m_match_flag_buffer

uchar* MultiRangeRowIterator::m_match_flag_buffer = nullptr
private

See set_match_flag_buffer().

◆ m_mrr_buffer

HANDLER_BUFFER MultiRangeRowIterator::m_mrr_buffer
private

Temporary space for storing inner rows, used by MRR.

Set by set_mrr_buffer().

◆ m_mrr_flags

const int MultiRangeRowIterator::m_mrr_flags
private

Flags passed on to MRR.

◆ m_outer_input_tables

pack_rows::TableCollection MultiRangeRowIterator::m_outer_input_tables
private

Tables and columns needed for each outer row.

Same as m_outer_input_tables in the corresponding BKAIterator.

◆ m_ref

TABLE_REF* const MultiRangeRowIterator::m_ref
private

The index condition.


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