1#ifndef SQL_SORT_INCLUDED
2#define SQL_SORT_INCLUDED
209 size_t max_output_rows) {
219 template <
bool Packed_addon_fields>
289template <
typename Heap_type>
291 typename Heap_type::iterator it = heap->begin();
292 typename Heap_type::iterator
end = heap->end();
293 for (; it !=
end; ++it) {
This class wraps information about usage of addon fields.
Definition: sort_param.h:128
Buffer used for storing records to be sorted.
Definition: filesort_utils.h:80
uchar ** get_sort_keys()
Get the list of record pointers as a contiguous array.
Definition: filesort_utils.h:190
void reset()
Prepares the buffer for the next batch of records to process.
Definition: filesort_utils.cc:248
bool preallocate_records(size_t num_records)
Removes any existing rows and allocates num_records maximum-sized rows (call get_sorted_record() to g...
Definition: filesort_utils.cc:276
Bounds_checked_array< uchar > get_next_record_pointer(size_t min_size)
Where should the next record be stored?
Definition: filesort_utils.h:115
size_t peak_memory_used() const
How much memory has been allocated (counting both the sort buffer and the record pointers) at most si...
Definition: filesort_utils.h:152
void clear_peak_memory_used()
See peak_memory_used.
Definition: filesort_utils.h:158
size_t sort_buffer(Sort_param *param, size_t num_input_rows, size_t max_output_rows)
Sort me...
Definition: filesort_utils.cc:130
void free_sort_buffer()
Frees all memory.
Definition: filesort_utils.cc:414
void commit_used_memory(size_t num_bytes)
Definition: filesort_utils.h:128
Bounds_checked_array< uchar > get_contiguous_buffer()
Clears all rows, then returns a contiguous buffer of maximum size.
Definition: filesort_utils.cc:436
size_t max_size_in_bytes() const
Definition: filesort_utils.h:144
void set_max_size(size_t max_size, size_t record_length)
Set the memory limit for the sort buffer before starting to add records.
Definition: filesort_utils.h:170
uchar * get_sorted_record(size_t ix)
Gets sorted record number ix.
Definition: filesort_utils.h:199
A class wrapping misc buffers used for sorting.
Definition: sql_sort.h:188
void free_sort_buffer()
Definition: sql_sort.h:260
Addon_fields * addon_fields
Addon field descriptors.
Definition: sql_sort.h:195
bool preallocate_records(size_t num_records)
Definition: sql_sort.h:262
void clear_peak_memory_used()
Definition: sql_sort.h:236
Filesort_info & operator=(const Filesort_info &)=delete
uchar ** get_sort_keys()
Definition: sql_sort.h:250
void commit_used_memory(size_t num_bytes)
Definition: sql_sort.h:242
void unpack_addon_fields(const Mem_root_array< TABLE * > &tables, uchar *buff)
Copies (unpacks) values appended to sorted fields from a buffer back to their regular positions speci...
Definition: sorting_iterator.cc:541
Filesort_info()
Definition: sql_sort.h:203
bool using_addon_fields() const
Are we using "addon fields"?
Definition: sql_sort.h:232
void read_chunk_descriptors(IO_CACHE *chunk_file, uint count)
Reads 'count' number of chunk descriptors into the merge_chunks array.
Definition: filesort.cc:709
bool m_using_varlen_keys
Definition: sql_sort.h:197
void set_sort_length(uint val, bool is_varlen)
Definition: sql_sort.h:275
bool using_varlen_keys() const
Definition: sql_sort.h:273
Merge_chunk_array merge_chunks
Array of chunk descriptors.
Definition: sql_sort.h:193
Filesort_buffer filesort_buffer
Buffer for sorting keys.
Definition: sql_sort.h:190
uint m_sort_length
Definition: sql_sort.h:198
size_t sort_buffer(Sort_param *param, size_t num_input_rows, size_t max_output_rows)
Sort filesort_buffer.
Definition: sql_sort.h:208
size_t max_size_in_bytes() const
Definition: sql_sort.h:268
uchar * get_sorted_record(uint idx)
Definition: sql_sort.h:246
Bounds_checked_array< uchar > get_contiguous_buffer()
Definition: sql_sort.h:252
void reset()
Definition: sql_sort.h:234
void set_max_size(size_t max_size, size_t record_length)
Definition: sql_sort.h:256
uint sort_length() const
Definition: sql_sort.h:272
size_t peak_memory_used() const
Definition: sql_sort.h:266
Bounds_checked_array< uchar > get_next_record_pointer(size_t min_size)
Definition: sql_sort.h:238
Filesort_info(const Filesort_info &)=delete
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:425
There are several record formats for sorting:
Definition: sort_param.h:301
Definition: sql_sort.h:155
IO_CACHE * io_cache
Definition: sql_sort.h:167
bool has_result() const
Definition: sql_sort.h:163
unique_ptr_my_free< uchar > sorted_result
Definition: sql_sort.h:179
Sort_result()
Definition: sql_sort.h:157
uchar * sorted_result_end
Definition: sql_sort.h:180
bool has_result_in_memory() const
Definition: sql_sort.h:159
bool sorted_result_in_fsbuf
If the entire result fits in memory, we skip the merge phase.
Definition: sql_sort.h:178
ha_rows found_records
How many records in sort.
Definition: sql_sort.h:182
plugin_messages_callback mc
Definition: fido_client_plugin.cc:51
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
bool my_b_inited(const IO_CACHE *info)
Definition: my_sys.h:492
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:176
std::unique_ptr< T, My_free_deleter > unique_ptr_my_free
std::unique_ptr, but with my_free as deleter.
Definition: map_helpers.h:96
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1139
ulonglong my_off_t
Definition: my_inttypes.h:71
unsigned char uchar
Definition: my_inttypes.h:51
Common header for many mysys elements.
static int count
Definition: myisam_ftdump.cc:44
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
constexpr size_t MERGEBUFF2
Definition: sql_sort.h:40
Bounds_checked_array< Merge_chunk > Merge_chunk_array
Definition: sql_sort.h:142
constexpr size_t MERGEBUFF
Definition: sql_sort.h:39
constexpr size_t VARLEN_PREFIX
Definition: sql_sort.h:42
void reuse_freed_buff(Merge_chunk *old_top, Heap_type *heap)
Put all room used by freed buffer to use in adjacent buffer.
Definition: sql_sort.h:290
Bounds_checked_array< uchar > Sort_buffer
Definition: sql_sort.h:281
Descriptor for a merge chunk to be sort-merged.
Definition: sql_sort.h:56
const uchar * buffer_end() const
Definition: sql_sort.h:63
uchar * m_buffer_start
Start of main-memory buffer for this chunk.
Definition: sql_sort.h:124
void init_current_key()
Definition: sql_sort.h:80
bool merge_freed_buff(Merge_chunk *mc) const
Tries to merge *this with *mc, returns true if successful.
Definition: sql_sort.h:103
ha_rows m_rowcount
Number of unread rows in this chunk.
Definition: sql_sort.h:133
void set_mem_count(ha_rows val)
Definition: sql_sort.h:89
void set_buffer_start(uchar *start)
Definition: sql_sort.h:70
void advance_current_key(uint val)
Definition: sql_sort.h:82
ha_rows mem_count() const
Definition: sql_sort.h:88
void set_file_position(my_off_t val)
Definition: sql_sort.h:59
void set_max_keys(ha_rows val)
Definition: sql_sort.h:93
void advance_file_position(my_off_t val)
Definition: sql_sort.h:60
my_off_t m_file_position
Current position in the file to be sorted.
Definition: sql_sort.h:121
uchar * m_valid_buffer_end
End of actual, valid data for this chunk.
Definition: sql_sort.h:130
ha_rows rowcount() const
Definition: sql_sort.h:86
void decrement_rowcount(ha_rows val)
Definition: sql_sort.h:84
void set_valid_buffer_end(uchar *end)
Definition: sql_sort.h:75
void set_buffer(uchar *start, uchar *end)
Definition: sql_sort.h:66
my_off_t file_position() const
Definition: sql_sort.h:58
ha_rows decrement_mem_count()
Definition: sql_sort.h:90
void set_rowcount(ha_rows val)
Definition: sql_sort.h:85
void set_buffer_end(uchar *end)
Definition: sql_sort.h:71
size_t buffer_size() const
Definition: sql_sort.h:95
ha_rows max_keys() const
Definition: sql_sort.h:92
ha_rows m_max_keys
If we have fixed-size rows: max number of rows in buffer.
Definition: sql_sort.h:139
const uchar * valid_buffer_end() const
Definition: sql_sort.h:64
uchar * m_current_key
The current key for this chunk.
Definition: sql_sort.h:118
uchar * current_key() const
Definition: sql_sort.h:81
ha_rows m_mem_count
Number of rows in the main-memory buffer.
Definition: sql_sort.h:136
uchar * m_buffer_end
End of main-memory buffer for this chunk.
Definition: sql_sort.h:127
uchar * buffer_start()
Definition: sql_sort.h:62