Skip to content

Commit

Permalink
fix last label issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanhaoji2 committed Oct 7, 2023
1 parent 84e02e2 commit 6ff2a38
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pq_flash_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,9 @@ void PQFlashIndex<T, LabelT>::get_label_file_metadata(const std::string &fileCon
while (lbl_pos < next_pos && lbl_pos != std::string::npos)
{
next_lbl_pos = fileContent.find(',', lbl_pos);
if (next_lbl_pos == std::string::npos)
if (next_lbl_pos == std::string::npos) // the last label
{
break;
next_lbl_pos = next_pos;
}

num_total_labels++;
Expand Down Expand Up @@ -689,9 +689,9 @@ void PQFlashIndex<T, LabelT>::parse_label_file(const std::string &label_file, si
while (lbl_pos < next_pos && lbl_pos != std::string::npos)
{
next_lbl_pos = buffer.find(',', lbl_pos);
if (next_lbl_pos == std::string::npos)
if (next_lbl_pos == std::string::npos) // the last label in the whole file
{
break;
next_lbl_pos = next_pos;
}

if (next_lbl_pos > next_pos) // the last label in one line
Expand Down

0 comments on commit 6ff2a38

Please sign in to comment.