mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-21580: Allow packed sort keys in sort buffer
This task deals with packing the sort key inside the sort buffer, which would lead to efficient usage of the memory allocated for the sort buffer. The changes brought by this feature are 1) Sort buffers would have sort keys of variable length 2) The format for sort keys inside the sort buffer would look like |<sort_length><null_byte><key_part1><null_byte><key_part2>.......| sort_length is the extra bytes that are required to store the variable length of a sort key. 3) When packing of sort key is done we store the ORIGINAL VALUES inside the sort buffer and not the STRXFRM form (mem-comparable sort keys). 4) Special comparison function packed_keys_comparison() is introduced to compare 2 sort keys. This patch also contains contributions from Sergei Petrunia.
This commit is contained in:
@ -59,7 +59,8 @@ public:
|
||||
*/
|
||||
typedef uint (*keymaker_function)(Sort_param *param,
|
||||
Key_type *to,
|
||||
Element_type *from);
|
||||
Element_type *from,
|
||||
bool packing_keys);
|
||||
|
||||
/**
|
||||
Function for comparing two keys.
|
||||
@ -181,11 +182,12 @@ void Bounded_queue<Element_type, Key_type>::push(Element_type *element)
|
||||
{
|
||||
// Replace top element with new key, and re-order the queue.
|
||||
Key_type **pq_top= reinterpret_cast<Key_type **>(queue_top(&m_queue));
|
||||
(void)(*m_keymaker)(m_sort_param, *pq_top, element);
|
||||
(void)(*m_keymaker)(m_sort_param, *pq_top, element, false);
|
||||
queue_replace_top(&m_queue);
|
||||
} else {
|
||||
// Insert new key into the queue.
|
||||
(*m_keymaker)(m_sort_param, m_sort_keys[m_queue.elements], element);
|
||||
(*m_keymaker)(m_sort_param, m_sort_keys[m_queue.elements],
|
||||
element, false);
|
||||
queue_insert(&m_queue,
|
||||
reinterpret_cast<uchar*>(&m_sort_keys[m_queue.elements]));
|
||||
}
|
||||
|
Reference in New Issue
Block a user