@@ -592,7 +592,7 @@ void PQFlashIndex<T, LabelT>::get_label_file_metadata(const std::string &fileCon
592
592
size_t next_lbl_pos = 0 ;
593
593
while (lbl_pos < next_pos && lbl_pos != std::string::npos)
594
594
{
595
- next_lbl_pos = fileContent. find ( ' ,' , lbl_pos);
595
+ next_lbl_pos = search_string_range (fileContent, ' ,' , lbl_pos, next_pos );
596
596
if (next_lbl_pos == std::string::npos) // the last label
597
597
{
598
598
next_lbl_pos = next_pos;
@@ -671,7 +671,7 @@ void PQFlashIndex<T, LabelT>::parse_label_file(std::basic_istream<char> &infile,
671
671
size_t next_lbl_pos = 0 ;
672
672
while (lbl_pos < next_pos && lbl_pos != std::string::npos)
673
673
{
674
- next_lbl_pos = buffer. find ( ' ,' , lbl_pos);
674
+ next_lbl_pos = search_string_range (buffer, ' ,' , lbl_pos, next_pos );
675
675
if (next_lbl_pos == std::string::npos) // the last label in the whole file
676
676
{
677
677
next_lbl_pos = next_pos;
@@ -810,7 +810,7 @@ int PQFlashIndex<T, LabelT>::load_from_separate_paths(uint32_t num_threads, cons
810
810
}
811
811
#endif
812
812
parse_label_file (infile, num_pts_in_label_file);
813
- assert (num_pts_in_label_file == this ->_num_points );
813
+ assert (num_pts_in_label_file == this ->num_points );
814
814
815
815
#ifndef EXEC_ENV_OLS
816
816
infile.close ();
@@ -1766,6 +1766,20 @@ template <typename T, typename LabelT> char *PQFlashIndex<T, LabelT>::getHeaderB
1766
1766
}
1767
1767
#endif
1768
1768
1769
+ template <typename T, typename LabelT>
1770
+ size_t PQFlashIndex<T, LabelT>::search_string_range (const std::string &str, char ch, size_t start, size_t end)
1771
+ {
1772
+ for (; start != end; start++)
1773
+ {
1774
+ if (str[start] == ch)
1775
+ {
1776
+ return start;
1777
+ }
1778
+ }
1779
+
1780
+ return std::string::npos;
1781
+ }
1782
+
1769
1783
// instantiations
1770
1784
template class PQFlashIndex <uint8_t >;
1771
1785
template class PQFlashIndex <int8_t >;
0 commit comments