mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
mhnsw: make the search less greedy
introduced a generosity factor that makes the search less greedy. it dramatically improves the recall by making the search a bit slower (for the same recall one can use half the M and smaller ef). had to add Queue::safe_push() method that removes one of the furthest elements (not necessarily the furthest) in the queue to keep it from overflowing.
This commit is contained in:
@@ -44,6 +44,11 @@ public:
|
||||
Element *top() const { return (Element*)queue_top(&m_queue); }
|
||||
|
||||
void push(const Element *element) { queue_insert(&m_queue, (uchar*)element); }
|
||||
void safe_push(const Element *element)
|
||||
{
|
||||
if (is_full()) m_queue.elements--; // remove one of the furthest elements
|
||||
queue_insert(&m_queue, (uchar*)element);
|
||||
}
|
||||
Element *pop() { return (Element *)queue_remove_top(&m_queue); }
|
||||
void clear() { queue_remove_all(&m_queue); }
|
||||
void propagate_top() { queue_replace_top(&m_queue); }
|
||||
|
Reference in New Issue
Block a user