MySQL  8.0.27
Source Code Documentation
Unique Class Reference

Unique – class for unique (removing of duplicates). More...

#include <uniques.h>

Public Types

typedef Bounds_checked_array< uintImerge_cost_buf_type
 

Public Member Functions

 Unique (qsort2_cmp comp_func, void *comp_func_fixed_arg, uint size_arg, ulonglong max_in_memory_size_arg)
 
 ~Unique ()
 
ulong elements_in_tree ()
 
bool unique_add (void *ptr)
 Add new value to Unique. More...
 
bool get (TABLE *table)
 
void reset ()
 
bool walk (tree_walk_action action, void *walk_action_arg)
 
uint get_size () const
 
ulonglong get_max_in_memory_size () const
 
bool is_in_memory ()
 

Static Public Member Functions

static double get_use_cost (Imerge_cost_buf_type buffer, uint nkeys, uint key_size, ulonglong max_in_memory_size, const Cost_model_table *cost_model)
 
static size_t get_cost_calc_buff_size (ulong nkeys, uint key_size, ulonglong max_in_memory_size)
 

Public Attributes

ulong elements
 

Private Member Functions

bool flush ()
 Flush tree to disk. More...
 

Private Attributes

Prealloced_array< Merge_chunk, 16 > file_ptrs
 Array of file pointers. More...
 
ulong max_elements
 Max elements in memory buffer. More...
 
ulonglong max_in_memory_size
 Memory buffer size. More...
 
IO_CACHE file
 Cache file for unique values retrieval fo table read AM in executor. More...
 
TREE tree
 Tree to filter duplicates in memory. More...
 
ucharrecord_pointers
 
uint size
 Element size. More...
 

Friends

int unique_write_to_file (void *v_key, element_count count, void *unique)
 
int unique_write_to_ptrs (void *v_key, element_count count, void *unique)
 

Detailed Description

Unique – class for unique (removing of duplicates).

Puts all values to the TREE. If the tree becomes too big, it's dumped to the file. User can request sorted values, or just iterate through them. In the last case tree merging is performed in memory simultaneously with iteration, so it should be ~2-3x faster.

Unique values can be read only from final result (not on insert) because duplicate values can be contained in different dumped tree files.

Member Typedef Documentation

◆ Imerge_cost_buf_type

Constructor & Destructor Documentation

◆ Unique()

Unique::Unique ( qsort2_cmp  comp_func,
void *  comp_func_fixed_arg,
uint  size_arg,
ulonglong  max_in_memory_size_arg 
)

◆ ~Unique()

Unique::~Unique ( )

Member Function Documentation

◆ elements_in_tree()

ulong Unique::elements_in_tree ( )
inline

◆ flush()

bool Unique::flush ( )
private

Flush tree to disk.

◆ get()

bool Unique::get ( TABLE table)

◆ get_cost_calc_buff_size()

static size_t Unique::get_cost_calc_buff_size ( ulong  nkeys,
uint  key_size,
ulonglong  max_in_memory_size 
)
inlinestatic

◆ get_max_in_memory_size()

ulonglong Unique::get_max_in_memory_size ( ) const
inline

◆ get_size()

uint Unique::get_size ( ) const
inline

◆ get_use_cost()

double Unique::get_use_cost ( Imerge_cost_buf_type  buffer,
uint  nkeys,
uint  key_size,
ulonglong  max_in_memory_size,
const Cost_model_table cost_model 
)
static

◆ is_in_memory()

bool Unique::is_in_memory ( )
inline

◆ reset()

void Unique::reset ( void  )

◆ unique_add()

bool Unique::unique_add ( void *  ptr)
inline

Add new value to Unique.

The value is inserted either to the tree, or to the duplicate weedout table, depending on the mode of operation. If tree's mem buffer is full, it's flushed to the disk.

Parameters
ptrpointer to the binary string to insert
Returns
false error or duplicate true the value was inserted

◆ walk()

bool Unique::walk ( tree_walk_action  action,
void *  walk_action_arg 
)

Friends And Related Function Documentation

◆ unique_write_to_file

int unique_write_to_file ( void *  v_key,
element_count  count,
void *  unique 
)
friend

◆ unique_write_to_ptrs

int unique_write_to_ptrs ( void *  v_key,
element_count  count,
void *  unique 
)
friend

Member Data Documentation

◆ elements

ulong Unique::elements

◆ file

IO_CACHE Unique::file
private

Cache file for unique values retrieval fo table read AM in executor.

◆ file_ptrs

Prealloced_array<Merge_chunk, 16> Unique::file_ptrs
private

Array of file pointers.

◆ max_elements

ulong Unique::max_elements
private

Max elements in memory buffer.

◆ max_in_memory_size

ulonglong Unique::max_in_memory_size
private

Memory buffer size.

◆ record_pointers

uchar* Unique::record_pointers
private

◆ size

uint Unique::size
private

Element size.

◆ tree

TREE Unique::tree
private

Tree to filter duplicates in memory.


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