Skip to content

Commit

Permalink
Fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanhaoji2 committed Mar 5, 2024
1 parent 7acac92 commit 2f5c7a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ template <typename T, typename TagT = uint32_t, typename LabelT = uint32_t> clas
DISKANN_DLLEXPORT size_t load_delete_set(const std::string &filename);
#endif

size_t search_string_range(const std::string& str, char ch, size_t start, size_t end);

private:
// Distance functions
Metric _dist_metric = diskann::L2;
Expand Down
16 changes: 15 additions & 1 deletion src/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2156,7 +2156,7 @@ void Index<T, TagT, LabelT>::parse_label_file_in_bitset(const std::string& label
size_t next_lbl_pos = 0;
while (lbl_pos < next_pos && lbl_pos != std::string::npos)
{
next_lbl_pos = buffer.find(',', lbl_pos);
next_lbl_pos = search_string_range(buffer, ',', lbl_pos, next_pos);
if (next_lbl_pos == std::string::npos) // the last label in the whole file
{
next_lbl_pos = next_pos;
Expand Down Expand Up @@ -3566,6 +3566,20 @@ void Index<T, TagT, LabelT>::search_with_optimized_layout(const T *query, size_t
}
}

template <typename T, typename TagT, typename LabelT>
size_t Index<T, TagT, LabelT>::search_string_range(const std::string& str, char ch, size_t start, size_t end)
{
for (; start != end; start++)
{
if (str[start] == ch)
{
return start;
}
}

return std::string::npos;
}

/* Internals of the library */
template <typename T, typename TagT, typename LabelT> const float Index<T, TagT, LabelT>::INDEX_GROWTH_FACTOR = 1.5f;

Expand Down

0 comments on commit 2f5c7a0

Please sign in to comment.