|
| uint32_t | sortlength (SortField *sortorder, uint32_t s_length, bool *multi_byte_charset) |
| sort_addon_field * | get_addon_fields (Field **ptabfield, uint32_t sortlength, uint32_t *plength) |
| ha_rows | find_all_keys (SortParam *param, optimizer::SqlSelect *select, unsigned char **sort_keys, internal::io_cache_st *buffpek_pointers, internal::io_cache_st *tempfile, internal::io_cache_st *indexfile) |
| int | merge_buffers (SortParam *param, internal::io_cache_st *from_file, internal::io_cache_st *to_file, unsigned char *sort_buffer, buffpek *lastbuff, buffpek *Fb, buffpek *Tb, int flag) |
| int | merge_index (SortParam *param, unsigned char *sort_buffer, buffpek *buffpek, uint32_t maxbuffer, internal::io_cache_st *tempfile, internal::io_cache_st *outfile) |
| int | merge_many_buff (SortParam *param, unsigned char *sort_buffer, buffpek *buffpek, uint32_t *maxbuffer, internal::io_cache_st *t_file) |
| uint32_t | read_to_buffer (internal::io_cache_st *fromfile, buffpek *buffpek, uint32_t sort_length) |
Definition at line 36 of file filesort.h.
◆ FileSort()
| drizzled::FileSort::FileSort |
( |
Session & | arg | ) |
|
◆ find_all_keys()
Search after sort_keys and write them into tempfile. All produced sequences are guaranteed to be non-empty.
- Parameters
-
| param | Sorting parameter |
| select | Use this to get source data |
| sort_keys | Array of pointers to sort key + addon buffers. |
| buffpek_pointers | File to write buffpeks describing sorted segments in tempfile. |
| tempfile | File to write sorted sequences of sortkeys to. |
| indexfile | If !NULL, use it for source data (contains rowids) |
- Note
- Basic idea:
while (get_next_sortkey())
{
if (no free space in sort_keys buffers)
{
sort sort_keys buffer;
dump sorted sequence to 'tempfile';
dump buffpek describing sequence location into 'buffpek_pointers';
}
put sort key into 'sort_keys';
}
if (sort_keys has some elements && dumped at least once)
sort-dump-dump as above;
else
don't sort, leave sort_keys array to be sorted by caller.
- Return values
-
| Number | of records written on success. |
| HA_POS_ERROR | on error. |
Definition at line 524 of file filesort.cc.
◆ get_addon_fields()
| sort_addon_field * drizzled::FileSort::get_addon_fields |
( |
Field ** | ptabfield, |
|
|
uint32_t | sortlength_arg, |
|
|
uint32_t * | plength ) |
|
private |
Get descriptors of fields appended to sorted fields and calculate its total length.
The function first finds out what fields are used in the result set. Then it calculates the length of the buffer to store the values of these fields together with the value of sort values. If the calculated length is not greater than max_length_for_sort_data the function allocates memory for an array of descriptors containing layouts for the values of the non-sorted fields in the buffer and fills them.
- Parameters
-
| ptabfield | Array of references to the table fields |
| sortlength | Total length of sorted fields |
| [out] | plength | Total length of appended fields |
- Note
- The null bits for the appended values are supposed to be put together and stored the buffer just ahead of the value of the first field.
- Returns
- Pointer to the layout descriptors for the appended fields, if any
- Return values
-
| NULL | if we do not store field values with sort data. |
Definition at line 1543 of file filesort.cc.
◆ getSession()
| Session & drizzled::FileSort::getSession |
( |
| ) |
|
|
inline |
◆ merge_buffers()
Merge buffers to one buffer.
- Parameters
-
| param | Sort parameter |
| from_file | File with source data (buffpeks 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. |
| lastbuff | OUT Store here buffpek describing data written to to_file |
| Fb | First element in source buffpeks array |
| Tb | Last element in source buffpeks array |
| flag | |
- Return values
-
Definition at line 1186 of file filesort.cc.
◆ merge_index()
◆ merge_many_buff()
Merge buffers to make < MERGEBUFF2 buffers.
Definition at line 1069 of file filesort.cc.
◆ read_to_buffer()
Read data to buffer.
- Return values
-
| (uint32_t)-1 | if something goes wrong |
Definition at line 1129 of file filesort.cc.
◆ run()
| ha_rows drizzled::FileSort::run |
( |
Table * | table, |
|
|
SortField * | sortorder, |
|
|
uint32_t | s_length, |
|
|
optimizer::SqlSelect * | select, |
|
|
ha_rows | max_rows, |
|
|
bool | sort_positions, |
|
|
ha_rows & | examined_rows ) |
Sort a table. Creates a set of pointers that can be used to read the rows in sorted order. This should be done with the functions in records.cc.
Before calling filesort, one must have done table->file->info(HA_STATUS_VARIABLE)
The result set is stored in table->io_cache or table->record_pointers.
- Parameters
-
| table | Table to sort |
| sortorder | How to sort the table |
| s_length | Number of elements in sortorder |
| select | condition to apply to the rows |
| max_rows | Return only this many rows |
| sort_positions | Set to 1 if we want to force sorting by position (Needed by UPDATE/INSERT or ALTER Table) |
| examined_rows | Store number of examined rows here |
- Todo
- check why we do this (param.keys–)
- Note
- If we sort by position (like if sort_positions is 1) filesort() will call table->prepare_for_position().
- Return values
-
# Number of rows
- Return values
-
| examined_rows | will be set to number of examined rows |
Definition at line 189 of file filesort.cc.
◆ sortlength()
| uint32_t drizzled::FileSort::sortlength |
( |
SortField * | sortorder, |
|
|
uint32_t | s_length, |
|
|
bool * | multi_byte_charset ) |
|
private |
Calculate length of sort key.
- Parameters
-
| sortorder | Order of items to sort |
| s_length | Number of items to sort |
| [out] | multi_byte_charset | Set to 1 if we are using multi-byte charset (In which case we have to use strxnfrm()) |
- Note
- sortorder->length is updated for each sort item.
sortorder->need_strxnfrm is set 1 if we have to use strxnfrm
- Returns
- Total length of sort buffer in bytes
Definition at line 1440 of file filesort.cc.
◆ _session
| Session& drizzled::FileSort::_session |
|
private |
The documentation for this class was generated from the following files: