MySQL 8.4.3
Source Code Documentation
|
#include "sql/uniques.h"
#include <string.h>
#include <algorithm>
#include <atomic>
#include <cmath>
#include <vector>
#include "my_base.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_io.h"
#include "my_tree.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/psi/mysql_file.h"
#include "mysql/service_mysql_alloc.h"
#include "priority_queue.h"
#include "sql/field.h"
#include "sql/handler.h"
#include "sql/malloc_allocator.h"
#include "sql/merge_many_buff.h"
#include "sql/mysqld.h"
#include "sql/opt_costmodel.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_executor.h"
#include "sql/sql_sort.h"
#include "sql/sql_tmp_table.h"
#include "sql/table.h"
Classes | |
struct | anonymous_namespace{uniques.cc}::Merge_chunk_compare_context |
class | anonymous_namespace{uniques.cc}::Uniq_param |
struct | anonymous_namespace{uniques.cc}::Merge_chunk_less |
Namespaces | |
namespace | anonymous_namespace{uniques.cc} |
Functions | |
static uint | uniq_read_to_buffer (IO_CACHE *fromfile, Merge_chunk *merge_chunk, Uniq_param *param) |
Read data to buffer. More... | |
static int | merge_buffers (THD *thd, Uniq_param *param, IO_CACHE *from_file, IO_CACHE *to_file, Sort_buffer sort_buffer, Merge_chunk *last_chunk, Merge_chunk_array chunk_array, int flag) |
Merge buffers to one buffer. More... | |
int | unique_write_to_file (void *v_key, element_count, void *v_unique) |
int | unique_write_to_ptrs (void *v_key, element_count, void *v_unique) |
static double | log2_n_fact (ulong n) |
Calculate log2(n!) More... | |
static double | get_merge_buffers_cost (size_t total_buf_elems, size_t n_buffers, uint elem_size, const Cost_model_table *cost_model) |
static double | get_merge_many_buffs_cost (uint num_full_buffers, uint elems_per_buffer, uint additional_num_elems, int elem_size, const Cost_model_table *cost_model) |
static int | merge_chunk_compare (Merge_chunk_compare_context *ctx, uchar *key_ptr1, uchar *key_ptr2) |
static bool | merge_walk (uchar *merge_buffer, size_t merge_buffer_size, size_t key_length, Merge_chunk *begin, Merge_chunk *end, tree_walk_action walk_action, void *walk_action_arg, qsort2_cmp compare, const void *compare_arg, IO_CACHE *file) |
|
static |
|
static |
|
inlinestatic |
Calculate log2(n!)
Stirling's approximate formula is used:
n! ~= sqrt(2*M_PI*n) * (n/M_E)^n
Derivation of formula used for calculations is as follows:
log2(n!) = log2(sqrt(2*M_PI*n)*(n/M_E)^n)
= log2(2*M_PI*n)/2 + n*log2(n/M_E)
= log2(2*M_PI)/2 + log2(n)/2 + n * (log2(n) - M_LOG2E);
n | the number to calculate log2(n!) for |
|
static |
Merge buffers to one buffer.
thd | thread context | |
param | Sort parameter | |
from_file | File with source data (Merge_chunks point to this file) | |
to_file | File to write the sorted result data. | |
sort_buffer | Buffer for data to store up to MERGEBUFF2 sort keys. | |
[out] | last_chunk | Store here Merge_chunk describing data written to to_file. |
chunk_array | Array of chunks to merge. | |
flag | 0 - write full record, 1 - write addon/ref |
0 | OK |
other | error |
|
static |
|
static |
|
static |
Read data to buffer.
int unique_write_to_file | ( | void * | v_key, |
element_count | count, | ||
void * | v_unique | ||
) |
int unique_write_to_ptrs | ( | void * | v_key, |
element_count | count, | ||
void * | v_unique | ||
) |