MySQL 9.1.0
Source Code Documentation
temptable::Indexed_cells Class Reference

Indexed cells represent one or more cells that are covered by an index. More...

#include <indexed_cells.h>

Public Member Functions

 Indexed_cells (const unsigned char *mysql_search_cells, uint16_t mysql_search_cells_length, const Index &index)
 Construct from a MySQL indexed cells (eg index_read() input buffer). More...
 
 Indexed_cells (const unsigned char *mysql_row, const Index &index)
 Construct from a mysql row. More...
 
 Indexed_cells (const Row &row, const Index &index)
 Construct from a row in a table. More...
 
Storage::Elementrow () const
 Get the row of these indexed cells. More...
 
void export_row_to_mysql (const Columns &columns, unsigned char *mysql_row, size_t mysql_row_length) const
 Export the row of these indexed cells in the mysql row format (write_row()). More...
 
size_t number_of_cells () const
 Get the number of indexed cells. More...
 
void number_of_cells (size_t n)
 Set the number of indexed cells. More...
 
Cell cell (size_t i, const Index &index) const
 Get a given indexed cell. More...
 
int compare (const Indexed_cells &rhs, const Index &index) const
 Compare to another indexed cells object. More...
 

Private Types

enum class  Data_location : uint8_t { MYSQL_BUF_INDEX_READ , MYSQL_BUF_WRITE_ROW , ROW }
 Enum that designates where the actual user data is stored. More...
 

Private Member Functions

Cell cell_from_mysql_buf_index_read (size_t i, const Index &index) const
 Derive the Nth cell if m_data_location == Data_location::MYSQL_BUF_INDEX_READ. More...
 

Static Private Member Functions

static Cell cell_from_row (size_t i, const Index &index, const Row &row)
 Generate a cell from a temptable::Row object with a possibly reduced length, if a prefix index is used. More...
 

Private Attributes

Data_location m_data_location
 Flag indicating whether we are interpreting MySQL buffer or we have references to a temptable::Row object. More...
 
uint8_t m_number_of_cells
 Number of cells that are indexed. More...
 
uint16_t m_length
 MySQL search cells' length, used only when m_data_location == MYSQL_BUF_INDEX_READ. More...
 
union {
   const unsigned char *   m_mysql_buf
 Pointer to one of: More...
 
   const Row *   m_row
 Pointer to the row, used when m_data_location == ROW. More...
 
}; 
 Save space by putting the members in a union. More...
 

Detailed Description

Indexed cells represent one or more cells that are covered by an index.

Member Enumeration Documentation

◆ Data_location

enum class temptable::Indexed_cells::Data_location : uint8_t
strongprivate

Enum that designates where the actual user data is stored.

Enumerator
MYSQL_BUF_INDEX_READ 

The data is in a MySQL buffer in index_read() input format (MySQL search cells).

MYSQL_BUF_WRITE_ROW 

The data is in a MySQL buffer in write_row() format (MySQL row).

ROW 

The data is in temptable::Row.

Constructor & Destructor Documentation

◆ Indexed_cells() [1/3]

temptable::Indexed_cells::Indexed_cells ( const unsigned char *  mysql_search_cells,
uint16_t  mysql_search_cells_length,
const Index index 
)

Construct from a MySQL indexed cells (eg index_read() input buffer).

Parameters
[in]mysql_search_cellsSearch cells in "index_read() input" format. These must remain valid during the lifetime of the created `Indexed_cells` object.
[in]mysql_search_cells_lengthThe length of `mysql_search_cells` in bytes.
[in]indexMySQL index, used for querying metadata.

◆ Indexed_cells() [2/3]

temptable::Indexed_cells::Indexed_cells ( const unsigned char *  mysql_row,
const Index index 
)

Construct from a mysql row.

The row must remain valid during the lifetime of the created Indexed_cells object.

Parameters
[in]mysql_rowMySQL row.
[in]indexMySQL index whose cells this `Indexed_cells` represents.

◆ Indexed_cells() [3/3]

temptable::Indexed_cells::Indexed_cells ( const Row row,
const Index index 
)

Construct from a row in a table.

The row must remain valid during the lifetime of the created Indexed_cells object.

Parameters
[in]rowRow from which to create the indexed cells.
[in]indexMySQL index, used for querying metadata.

Member Function Documentation

◆ cell()

Cell temptable::Indexed_cells::cell ( size_t  i,
const Index index 
) const

Get a given indexed cell.

Returns
cell
Parameters
[in]iIndex of the cell within the indexed cells, must be in [0, number_of_cells()).
[in]indexIndex to which the current objects belongs, used for querying metadata.

◆ cell_from_mysql_buf_index_read()

Cell temptable::Indexed_cells::cell_from_mysql_buf_index_read ( size_t  i,
const Index index 
) const
private

Derive the Nth cell if m_data_location == Data_location::MYSQL_BUF_INDEX_READ.

Returns
Nth cell
Parameters
[in]iIndex of the cell within the indexed cells, must be in [0, number_of_cells()).
[in]indexIndex, for querying metadata via the MySQL index.

◆ cell_from_row()

Cell temptable::Indexed_cells::cell_from_row ( size_t  i,
const Index index,
const Row row 
)
staticprivate

Generate a cell from a temptable::Row object with a possibly reduced length, if a prefix index is used.

Parameters
[in]iIndexed cell number in the index. E.g. if we have a row (a, b, c, d) and an index on (b, c) and we want the cell `c`, then this will be 1.
[in]indexIndex to which the current objects belongs, used for querying metadata.
[in]rowRow that contains the data.

◆ compare()

int temptable::Indexed_cells::compare ( const Indexed_cells rhs,
const Index index 
) const

Compare to another indexed cells object.

Each cell is compared individually until a differing cells are found. If the compared objects contain different number of cells and all cells are equal up to the smaller object, then the objects are considered equal. E.g. (10, 15) == (10, 15, 23).

Return values
<0if this < rhs
0if this == rhs
>0if this > rhs
Parameters
[in]rhsIndexed cells to compare with the current object.
[in]indexIndex, used for querying metadata.

◆ export_row_to_mysql()

void temptable::Indexed_cells::export_row_to_mysql ( const Columns columns,
unsigned char *  mysql_row,
size_t  mysql_row_length 
) const
inline

Export the row of these indexed cells in the mysql row format (write_row()).

As with the row() method, this one does not make sense and must not be called if the current Indexed_cells object has been created from MySQL search cells.

Parameters
[in]columnsMetadata for the columns that constitute the exported row.
[out]mysql_rowBuffer to write the MySQL row into.
[in]mysql_row_lengthPresumed length of the mysql row in bytes.

◆ number_of_cells() [1/2]

size_t temptable::Indexed_cells::number_of_cells ( ) const
inline

Get the number of indexed cells.

Returns
number of indexed cells

◆ number_of_cells() [2/2]

void temptable::Indexed_cells::number_of_cells ( size_t  n)
inline

Set the number of indexed cells.

It only makes sense to reduce the number in order to compare less cells for the purposes of prefix search. We treat (10) == (10, 20).

◆ row()

Storage::Element * temptable::Indexed_cells::row ( ) const
inline

Get the row of these indexed cells.

There is no row if this Indexed_cells object has been created from a MySQL search cells (Handler::index_read() input), so this method must not be called in this case.

Returns
row, an element of Table::m_rows

Member Data Documentation

◆ 

union { ... } temptable::Indexed_cells::@212

Save space by putting the members in a union.

Exactly one of those is used.

◆ m_data_location

Data_location temptable::Indexed_cells::m_data_location
private

Flag indicating whether we are interpreting MySQL buffer or we have references to a temptable::Row object.

◆ m_length

uint16_t temptable::Indexed_cells::m_length
private

MySQL search cells' length, used only when m_data_location == MYSQL_BUF_INDEX_READ.

◆ m_mysql_buf

const unsigned char* temptable::Indexed_cells::m_mysql_buf

Pointer to one of:

  • MySQL search cells buffer (index_read() input format) used when m_data_location == MYSQL_BUF_INDEX_READ or
  • MySQL row in write_row() format used when m_data_location == MYSQL_BUF_WRITE_ROW.

◆ m_number_of_cells

uint8_t temptable::Indexed_cells::m_number_of_cells
private

Number of cells that are indexed.

◆ m_row

const Row* temptable::Indexed_cells::m_row

Pointer to the row, used when m_data_location == ROW.


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