@@ -54,7 +54,7 @@ class BruteforceSearch : public AlgorithmInterface<dist_t> {
5454 size_per_element_ = data_size_ + sizeof (labeltype);
5555 data_ = (char *) malloc (maxElements * size_per_element_);
5656 if (data_ == nullptr )
57- throw std::runtime_error (" Not enough memory: BruteforceSearch failed to allocate data" );
57+ HNSWLIB_THROW_RUNTIME_ERROR (" Not enough memory: BruteforceSearch failed to allocate data" );
5858 cur_element_count = 0 ;
5959 }
6060
@@ -64,7 +64,7 @@ class BruteforceSearch : public AlgorithmInterface<dist_t> {
6464 }
6565
6666
67- HNSWLIB_STATUS_TYPE addPoint (const void *datapoint, labeltype label, bool replace_deleted = false ) override {
67+ Status addPointNoExceptions (const void *datapoint, labeltype label, bool replace_deleted = false ) override {
6868 int idx;
6969 {
7070 std::unique_lock<std::mutex> lock (index_lock);
@@ -74,7 +74,7 @@ class BruteforceSearch : public AlgorithmInterface<dist_t> {
7474 idx = search->second ;
7575 } else {
7676 if (cur_element_count >= maxelements_) {
77- throw std::runtime_error (" The number of elements exceeds the specified limit\n " );
77+ HNSWLIB_THROW_RUNTIME_ERROR (" The number of elements exceeds the specified limit\n " );
7878 }
7979 idx = cur_element_count;
8080 dict_external_to_internal[label] = idx;
@@ -83,7 +83,7 @@ class BruteforceSearch : public AlgorithmInterface<dist_t> {
8383 }
8484 memcpy (data_ + size_per_element_ * idx + data_size_, &label, sizeof (labeltype));
8585 memcpy (data_ + size_per_element_ * idx, datapoint, data_size_);
86- HNSWLIB_RETURN_OK_STATUS ;
86+ return OkStatus () ;
8787 }
8888
8989
@@ -108,8 +108,8 @@ class BruteforceSearch : public AlgorithmInterface<dist_t> {
108108
109109
110110 using DistanceLabelPriorityQueue = typename AlgorithmInterface<dist_t >::DistanceLabelPriorityQueue;
111- HNSWLIB_STATUS_OR_TYPE ( DistanceLabelPriorityQueue)
112- searchKnn (const void *query_data, size_t k, BaseFilterFunctor* isIdAllowed = nullptr ) const override {
111+ StatusOr< DistanceLabelPriorityQueue>
112+ searchKnnNoExceptions (const void *query_data, size_t k, BaseFilterFunctor* isIdAllowed = nullptr ) const override {
113113 assert (k <= cur_element_count);
114114 std::priority_queue<std::pair<dist_t , labeltype >> topResults;
115115 if (cur_element_count == 0 ) return topResults;
@@ -168,7 +168,7 @@ class BruteforceSearch : public AlgorithmInterface<dist_t> {
168168 size_per_element_ = data_size_ + sizeof (labeltype);
169169 data_ = (char *) malloc (maxelements_ * size_per_element_);
170170 if (data_ == nullptr )
171- throw std::runtime_error (" Not enough memory: loadIndex failed to allocate data" );
171+ HNSWLIB_THROW_RUNTIME_ERROR (" Not enough memory: loadIndex failed to allocate data" );
172172
173173 input.read (data_, maxelements_ * size_per_element_);
174174
0 commit comments