Skip to content

Commit 764e012

Browse files
authored
Bug Fix: Sort Search Buffer Before Node Insertion (#211)
Summary: This PR fixes a bug in the Vamana index search buffer logic by adding a sort operation before inserting nodes. The change ensures that buffer invariants are maintained during the search process. Changes: - Added search_buffer.sort() call in check_and_supplement_search_buffer() function - Ensures proper ordering before inserting new nodes into the search buffer Impact: - Fixes potential correctness issues in Vamana index search operations - Maintains data structure invariants that were previously being violated - Performance impact is minimal as this code path is only executed in rare corner cases when: - The search buffer has fewer valid entries than the target window size - AND there are still unused nodes available in the index - This typically occurs when the graph becomes sparsely connected This is a targeted bug fix that addresses a specific issue where the search buffer wasn't properly sorted before node insertions in edge cases, which could lead to incorrect search results or violated invariants in the Vamana graph search algorithm.
1 parent b3558f0 commit 764e012

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

include/svs/index/vamana/extensions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ void check_and_supplement_search_buffer(
436436
) {
437437
if (search_buffer.valid() < search_buffer.target_window() &&
438438
search_buffer.valid() < index.size()) {
439+
search_buffer.sort();
439440
for (auto external_id : index.external_ids()) {
440441
auto internal_id = index.translate_external_id(external_id);
441442
auto dist = index.get_distance(external_id, query);

0 commit comments

Comments
 (0)