MySQL 8.0.40
Source Code Documentation
ddl::Key_sort_buffer Struct Reference

Buffer for sorting in main memory. More...

#include <ddl0impl-buffer.h>

Inheritance diagram for ddl::Key_sort_buffer:
[legend]

Public Types

using Function = std::function< dberr_t(IO_buffer io_buffer)>
 Callback for writing serialized data to to disk. More...
 
using DTuple = dfield_t *
 
using DTuples = std::vector< DTuple, ut::allocator< DTuple > >
 

Public Member Functions

 Key_sort_buffer (dict_index_t *index, size_t size) noexcept
 Constructor. More...
 
 ~Key_sort_buffer () noexcept
 Destructor. More...
 
void sort (ddl::Dup *dup) noexcept
 Sort the elements in m_dtuples. More...
 
dberr_t serialize (IO_buffer io_buffer, Function persist) noexcept
 Serialize the contents for storing to disk. More...
 
void clear () noexcept
 Reset the sort buffer. More...
 
bool is_clustered () const noexcept
 
bool is_fts () const noexcept
 
bool is_unique () const noexcept
 
mem_heap_theap () noexcept
 
size_t size () const noexcept
 
bool full () const noexcept
 
bool empty () const noexcept
 
dfield_t *& back () noexcept
 
dfield_talloc (size_t n) noexcept
 Allocate fields from the heap. More...
 
bool will_fit (size_t n) const noexcept
 Check if n bytes will fit in the buffer. More...
 
void deep_copy (size_t n_fields, size_t data_size) noexcept
 Deep copy the field data starting from the back. More...
 

Static Public Member Functions

static int compare (const dfield_t *lhs, const dfield_t *rhs, Dup *dup) noexcept
 Compare two merge data tuples. More...
 

Public Attributes

mem_heap_tm_heap {}
 Memory heap where allocated. More...
 
dict_index_tm_index {}
 The index the tuples belong to. More...
 
size_t m_total_size {}
 Total amount of data bytes. More...
 
size_t m_n_tuples {}
 Number of data tuples. More...
 
size_t m_max_tuples {}
 Maximum number of data tuples. More...
 
DTuples m_dtuples {}
 Array of data tuples. More...
 
size_t m_buffer_size {}
 Buffer size. More...
 

Additional Inherited Members

- Private Member Functions inherited from ut::Non_copyable
 Non_copyable (const Non_copyable &)=delete
 
Non_copyableoperator= (const Non_copyable &)=delete
 
 Non_copyable ()=default
 
 ~Non_copyable ()=default
 

Detailed Description

Buffer for sorting in main memory.

Member Typedef Documentation

◆ DTuple

◆ DTuples

◆ Function

using ddl::Key_sort_buffer::Function = std::function<dberr_t(IO_buffer io_buffer)>

Callback for writing serialized data to to disk.

Parameters
[in]io_bufferBuffer to persist - aligned to IO_BLOCK_SIZE.
Returns
DB_SUCCES or error code.

Constructor & Destructor Documentation

◆ Key_sort_buffer()

ddl::Key_sort_buffer::Key_sort_buffer ( dict_index_t index,
size_t  size 
)
explicitnoexcept

Constructor.

Parameters
[in,out]indexSort buffer is for this index.
[in]sizeSort buffer size in bytes.

◆ ~Key_sort_buffer()

ddl::Key_sort_buffer::~Key_sort_buffer ( )
inlinenoexcept

Destructor.

Member Function Documentation

◆ alloc()

dfield_t * ddl::Key_sort_buffer::alloc ( size_t  n)
inlinenoexcept

Allocate fields from the heap.

Parameters
[in]nNumber of fields to allocate.
Returns
an array of n dfields.

◆ back()

dfield_t *& ddl::Key_sort_buffer::back ( )
inlinenoexcept
Returns
a references to the last element.

◆ clear()

void ddl::Key_sort_buffer::clear ( )
noexcept

Reset the sort buffer.

clear the heap and entries.

◆ compare()

int ddl::Key_sort_buffer::compare ( const dfield_t lhs,
const dfield_t rhs,
Dup dup 
)
staticnoexcept

Compare two merge data tuples.

Parameters
[in]lhsFields to compare on the LHS
[in]rhsFields to compare on the RHS
[in,out]dupFor capturing duplicates (or nullptr).
Return values
+ve- if lhs > rhs
-ve- if lhs < rhs
0- if lhs == rhs

◆ deep_copy()

void ddl::Key_sort_buffer::deep_copy ( size_t  n_fields,
size_t  data_size 
)
noexcept

Deep copy the field data starting from the back.

Parameters
[in]n_fieldsNumber of fields to copy.
[in]data_sizeSize in bytes of the data to copy.

◆ empty()

bool ddl::Key_sort_buffer::empty ( ) const
inlinenoexcept
Returns
true if the buffer is empty.

◆ full()

bool ddl::Key_sort_buffer::full ( ) const
inlinenoexcept
Returns
true if the buffer is full.

◆ heap()

mem_heap_t * ddl::Key_sort_buffer::heap ( )
inlinenoexcept
Returns
the heap to use.

◆ is_clustered()

bool ddl::Key_sort_buffer::is_clustered ( ) const
inlinenoexcept
Returns
true if the index is clustered.

◆ is_fts()

bool ddl::Key_sort_buffer::is_fts ( ) const
inlinenoexcept
Returns
true if the index is an FTS index.

◆ is_unique()

bool ddl::Key_sort_buffer::is_unique ( ) const
inlinenoexcept
Returns
true if the index has a unique constraint.

◆ serialize()

dberr_t ddl::Key_sort_buffer::serialize ( IO_buffer  io_buffer,
Function  persist 
)
noexcept

Serialize the contents for storing to disk.

Parameters
[in]io_bufferBuffer for serializing.
[in]persistFunction for persisting the data.
Returns
DB_SUCCESS or error code.

◆ size()

size_t ddl::Key_sort_buffer::size ( ) const
inlinenoexcept
Returns
number of tuples stored so far.

◆ sort()

void ddl::Key_sort_buffer::sort ( ddl::Dup dup)
noexcept

Sort the elements in m_dtuples.

Parameters
[in,out]dupFor collecting the duplicate rows.

◆ will_fit()

bool ddl::Key_sort_buffer::will_fit ( size_t  n) const
inlinenoexcept

Check if n bytes will fit in the buffer.

Parameters
[in]nNumber of bytes to check.
Returns
true if n bytes will fit in the buffer.

Member Data Documentation

◆ m_buffer_size

size_t ddl::Key_sort_buffer::m_buffer_size {}

Buffer size.

◆ m_dtuples

DTuples ddl::Key_sort_buffer::m_dtuples {}

Array of data tuples.

◆ m_heap

mem_heap_t* ddl::Key_sort_buffer::m_heap {}

Memory heap where allocated.

◆ m_index

dict_index_t* ddl::Key_sort_buffer::m_index {}

The index the tuples belong to.

◆ m_max_tuples

size_t ddl::Key_sort_buffer::m_max_tuples {}

Maximum number of data tuples.

◆ m_n_tuples

size_t ddl::Key_sort_buffer::m_n_tuples {}

Number of data tuples.

◆ m_total_size

size_t ddl::Key_sort_buffer::m_total_size {}

Total amount of data bytes.


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