Skip to content

Commit

Permalink
Jegao/no neighbor at last point fix (#577)
Browse files Browse the repository at this point in the history
* fix debug crash issue

* fix out-range issue
  • Loading branch information
Sanhaoji2 authored Aug 14, 2024
1 parent 8b98118 commit 2d0b88f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/in_mem_static_graph_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ std::tuple<uint32_t, uint32_t, size_t> InMemStaticGraphStore::load_impl(const st
// resize graph
_node_index.resize(nodes_read + 1);
_node_index[0] = 0;
_graph.resize(cc);
// add one more slot than actually need to avoid read invaild address
// while the last point is no neighbor
_graph.resize(cc + 1);

// second round to insert graph data
nodes_read = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/pq_flash_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,9 @@ void PQFlashIndex<T, LabelT>::cached_beam_search(const T *query1, const uint64_t
}

// copy k_search values
for (uint64_t i = 0; i < k_search; i++)
uint64_t ret_count = full_retset.size() > k_search
? k_search : full_retset.size();
for (uint64_t i = 0; i < ret_count; i++)
{
indices[i] = full_retset[i].id;
auto key = (uint32_t)indices[i];
Expand Down

0 comments on commit 2d0b88f

Please sign in to comment.