MySQL 8.3.0
Source Code Documentation
ddl::Merge_file_sort Struct Reference

Merge the blocks in the file. More...

#include <ddl0impl-merge.h>

Classes

struct  Context
 Context to use for merging the files/runs. More...
 
struct  Cursor
 Cursor for merging blocks from the same file. More...
 
struct  Output_file
 For writing out the merged rows. More...
 

Public Types

using Range = std::pair< os_offset_t, os_offset_t >
 Start of the record lists to merge. More...
 

Public Member Functions

 Merge_file_sort (Context *merge_ctx) noexcept
 Constructor. More...
 
dberr_t sort (Builder *builder, Merge_offsets &offsets) noexcept
 Merge the the blocks. More...
 
uint64_t get_n_rows () const noexcept
 

Static Public Attributes

static constexpr size_t N_WAY_MERGE = 2
 The design is generalized as an N way merge, however we stick with 2 for now. More...
 

Private Member Functions

dberr_t merge_rows (Cursor &cursor, Output_file &output_file) noexcept
 Merge the rows. More...
 
dberr_t merge_ranges (Cursor &cursor, Merge_offsets &offsets, Output_file &output_file, size_t buffer_size) noexcept
 Merge the blocks in the ranges. More...
 
Range next_range (Merge_offsets &offsets) noexcept
 Move to the next range of pages to merge. More...
 

Private Attributes

Dupm_dup {}
 To check and report duplicates. More...
 
Contextm_merge_ctx {}
 Meta data for merging blocks. More...
 
Merge_offsets m_next_offsets {}
 Page numbers to merge for the next pass. More...
 
uint64_t m_n_rows {}
 Number of rows in the sorted file. More...
 

Detailed Description

Merge the blocks in the file.

Member Typedef Documentation

◆ Range

Start of the record lists to merge.

Constructor & Destructor Documentation

◆ Merge_file_sort()

ddl::Merge_file_sort::Merge_file_sort ( Context merge_ctx)
inlineexplicitnoexcept

Constructor.

Parameters
[in,out]merge_ctxData blocks merge meta data.

Member Function Documentation

◆ get_n_rows()

uint64_t ddl::Merge_file_sort::get_n_rows ( ) const
inlinenoexcept
Returns
the number of rows in the sorted file.

◆ merge_ranges()

dberr_t ddl::Merge_file_sort::merge_ranges ( Cursor cursor,
Merge_offsets offsets,
Output_file output_file,
size_t  buffer_size 
)
privatenoexcept

Merge the blocks in the ranges.

Parameters
[in,out]cursorTo iterate over the rows to merge.
[in,out]offsetsStarting offsets of record lists to merge.
[in,out]output_fileOutput file to write the merged rows.
[in]buffer_sizeIO buffer size for reads.
Returns
DB_SUCCESS or error code.

◆ merge_rows()

dberr_t ddl::Merge_file_sort::merge_rows ( Cursor cursor,
Output_file output_file 
)
privatenoexcept

Merge the rows.

Parameters
[in,out]cursorTo iterate over the rows to merge.
[in,out]output_fileOutput file to write the merged rows.
Returns
DB_SUCCESS or error code.

◆ next_range()

Merge_file_sort::Range ddl::Merge_file_sort::next_range ( Merge_offsets offsets)
privatenoexcept

Move to the next range of pages to merge.

Parameters
[in,out]offsetsCurrent offsets to start the merge from.
Returns
the next range to merge.

◆ sort()

dberr_t ddl::Merge_file_sort::sort ( Builder builder,
Merge_offsets offsets 
)
noexcept

Merge the the blocks.

Parameters
[in,out]builderBuilder instance used for building index.
[in,out]offsetsOffsets from where to start the merge.
Returns
DB_SUCCESS or error code.

Member Data Documentation

◆ m_dup

Dup* ddl::Merge_file_sort::m_dup {}
private

To check and report duplicates.

◆ m_merge_ctx

Context* ddl::Merge_file_sort::m_merge_ctx {}
private

Meta data for merging blocks.

◆ m_n_rows

uint64_t ddl::Merge_file_sort::m_n_rows {}
private

Number of rows in the sorted file.

◆ m_next_offsets

Merge_offsets ddl::Merge_file_sort::m_next_offsets {}
private

Page numbers to merge for the next pass.

◆ N_WAY_MERGE

constexpr size_t ddl::Merge_file_sort::N_WAY_MERGE = 2
staticconstexpr

The design is generalized as an N way merge, however we stick with 2 for now.


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