1#ifndef SQL_SORT_INCLUDED
2#define SQL_SORT_INCLUDED
210 size_t max_output_rows) {
220 template <
bool Packed_addon_fields>
290template <
typename Heap_type>
292 typename Heap_type::iterator it = heap->begin();
293 typename Heap_type::iterator
end = heap->end();
294 for (; it !=
end; ++it) {
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
This class wraps information about usage of addon fields.
Definition: sort_param.h:129
Buffer used for storing records to be sorted.
Definition: filesort_utils.h:81
uchar ** get_sort_keys()
Get the list of record pointers as a contiguous array.
Definition: filesort_utils.h:191
void reset()
Prepares the buffer for the next batch of records to process.
Definition: filesort_utils.cc:249
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:277
Bounds_checked_array< uchar > get_next_record_pointer(size_t min_size)
Where should the next record be stored?
Definition: filesort_utils.h:116
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:153
void clear_peak_memory_used()
See peak_memory_used.
Definition: filesort_utils.h:159
size_t sort_buffer(Sort_param *param, size_t num_input_rows, size_t max_output_rows)
Sort me...
Definition: filesort_utils.cc:131
void free_sort_buffer()
Frees all memory.
Definition: filesort_utils.cc:415
void commit_used_memory(size_t num_bytes)
Definition: filesort_utils.h:129
Bounds_checked_array< uchar > get_contiguous_buffer()
Clears all rows, then returns a contiguous buffer of maximum size.
Definition: filesort_utils.cc:437
size_t max_size_in_bytes() const
Definition: filesort_utils.h:145
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:171
uchar * get_sorted_record(size_t ix)
Gets sorted record number ix.
Definition: filesort_utils.h:200
A class wrapping misc buffers used for sorting.
Definition: sql_sort.h:189
void free_sort_buffer()
Definition: sql_sort.h:261
Addon_fields * addon_fields
Addon field descriptors.
Definition: sql_sort.h:196
bool preallocate_records(size_t num_records)
Definition: sql_sort.h:263
void clear_peak_memory_used()
Definition: sql_sort.h:237
Filesort_info & operator=(const Filesort_info &)=delete
uchar ** get_sort_keys()
Definition: sql_sort.h:251
void commit_used_memory(size_t num_bytes)
Definition: sql_sort.h:243
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:204
bool using_addon_fields() const
Are we using "addon fields"?
Definition: sql_sort.h:233
void read_chunk_descriptors(IO_CACHE *chunk_file, uint count)
Reads 'count' number of chunk descriptors into the merge_chunks array.
Definition: filesort.cc:710
bool m_using_varlen_keys
Definition: sql_sort.h:198
void set_sort_length(uint val, bool is_varlen)
Definition: sql_sort.h:276
bool using_varlen_keys() const
Definition: sql_sort.h:274
Merge_chunk_array merge_chunks
Array of chunk descriptors.
Definition: sql_sort.h:194
Filesort_buffer filesort_buffer
Buffer for sorting keys.
Definition: sql_sort.h:191
uint m_sort_length
Definition: sql_sort.h:199
size_t sort_buffer(Sort_param *param, size_t num_input_rows, size_t max_output_rows)
Sort filesort_buffer.
Definition: sql_sort.h:209
size_t max_size_in_bytes() const
Definition: sql_sort.h:269
uchar * get_sorted_record(uint idx)
Definition: sql_sort.h:247
Bounds_checked_array< uchar > get_contiguous_buffer()
Definition: sql_sort.h:253
void reset()
Definition: sql_sort.h:235
void set_max_size(size_t max_size, size_t record_length)
Definition: sql_sort.h:257
uint sort_length() const
Definition: sql_sort.h:273
size_t peak_memory_used() const
Definition: sql_sort.h:267
Bounds_checked_array< uchar > get_next_record_pointer(size_t min_size)
Definition: sql_sort.h:239
Filesort_info(const Filesort_info &)=delete
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
There are several record formats for sorting:
Definition: sort_param.h:302
Definition: sql_sort.h:156
IO_CACHE * io_cache
Definition: sql_sort.h:168
bool has_result() const
Definition: sql_sort.h:164
unique_ptr_my_free< uchar > sorted_result
Definition: sql_sort.h:180
Sort_result()
Definition: sql_sort.h:158
uchar * sorted_result_end
Definition: sql_sort.h:181
bool has_result_in_memory() const
Definition: sql_sort.h:160
bool sorted_result_in_fsbuf
If the entire result fits in memory, we skip the merge phase.
Definition: sql_sort.h:179
ha_rows found_records
How many records in sort.
Definition: sql_sort.h:183
bool my_b_inited(const IO_CACHE *info)
Definition: my_sys.h:495
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
std::unique_ptr< T, My_free_deleter > unique_ptr_my_free
std::unique_ptr, but with my_free as deleter.
Definition: map_helpers.h:97
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1141
ulonglong my_off_t
Definition: my_inttypes.h:72
unsigned char uchar
Definition: my_inttypes.h:52
Common header for many mysys elements.
static int count
Definition: myisam_ftdump.cc:45
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
constexpr size_t MERGEBUFF2
Definition: sql_sort.h:41
Bounds_checked_array< Merge_chunk > Merge_chunk_array
Definition: sql_sort.h:143
constexpr size_t MERGEBUFF
Definition: sql_sort.h:40
constexpr size_t VARLEN_PREFIX
Definition: sql_sort.h:43
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:291
Bounds_checked_array< uchar > Sort_buffer
Definition: sql_sort.h:282
Descriptor for a merge chunk to be sort-merged.
Definition: sql_sort.h:57
const uchar * buffer_end() const
Definition: sql_sort.h:64
uchar * m_buffer_start
Start of main-memory buffer for this chunk.
Definition: sql_sort.h:125
void init_current_key()
Definition: sql_sort.h:81
bool merge_freed_buff(Merge_chunk *mc) const
Tries to merge *this with *mc, returns true if successful.
Definition: sql_sort.h:104
ha_rows m_rowcount
Number of unread rows in this chunk.
Definition: sql_sort.h:134
void set_mem_count(ha_rows val)
Definition: sql_sort.h:90
void set_buffer_start(uchar *start)
Definition: sql_sort.h:71
void advance_current_key(uint val)
Definition: sql_sort.h:83
ha_rows mem_count() const
Definition: sql_sort.h:89
void set_file_position(my_off_t val)
Definition: sql_sort.h:60
void set_max_keys(ha_rows val)
Definition: sql_sort.h:94
void advance_file_position(my_off_t val)
Definition: sql_sort.h:61
my_off_t m_file_position
Current position in the file to be sorted.
Definition: sql_sort.h:122
uchar * m_valid_buffer_end
End of actual, valid data for this chunk.
Definition: sql_sort.h:131
ha_rows rowcount() const
Definition: sql_sort.h:87
void decrement_rowcount(ha_rows val)
Definition: sql_sort.h:85
void set_valid_buffer_end(uchar *end)
Definition: sql_sort.h:76
void set_buffer(uchar *start, uchar *end)
Definition: sql_sort.h:67
my_off_t file_position() const
Definition: sql_sort.h:59
ha_rows decrement_mem_count()
Definition: sql_sort.h:91
void set_rowcount(ha_rows val)
Definition: sql_sort.h:86
void set_buffer_end(uchar *end)
Definition: sql_sort.h:72
size_t buffer_size() const
Definition: sql_sort.h:96
ha_rows max_keys() const
Definition: sql_sort.h:93
ha_rows m_max_keys
If we have fixed-size rows: max number of rows in buffer.
Definition: sql_sort.h:140
const uchar * valid_buffer_end() const
Definition: sql_sort.h:65
uchar * m_current_key
The current key for this chunk.
Definition: sql_sort.h:119
uchar * current_key() const
Definition: sql_sort.h:82
ha_rows m_mem_count
Number of rows in the main-memory buffer.
Definition: sql_sort.h:137
uchar * m_buffer_end
End of main-memory buffer for this chunk.
Definition: sql_sort.h:128
uchar * buffer_start()
Definition: sql_sort.h:63
plugin_messages_callback mc
Definition: webauthn_client_plugin.cc:55