@@ -27,7 +27,7 @@ namespace hnswlib {
27
27
}
28
28
29
29
HierarchicalNSW (SpaceInterface<dist_t > *s, size_t max_elements, size_t M = 16 , size_t ef_construction = 200 , size_t random_seed = 100 ) :
30
- link_list_locks_ (max_elements), element_levels_(max_elements ), link_list_update_locks_(max_update_element_locks ) {
30
+ link_list_locks_ (max_elements), link_list_update_locks_(max_update_element_locks ), element_levels_(max_elements ) {
31
31
max_elements_ = max_elements;
32
32
33
33
has_deletions_=false ;
@@ -869,12 +869,12 @@ namespace hnswlib {
869
869
// continue;
870
870
871
871
std::priority_queue<std::pair<dist_t , tableint>, std::vector<std::pair<dist_t , tableint>>, CompareByFirst> candidates;
872
- int size = sCand .find (neigh) == sCand .end () ? sCand .size () : sCand .size () - 1 ;
873
- int elementsToKeep = std::min (int ( ef_construction_) , size);
872
+ size_t size = sCand .find (neigh) == sCand .end () ? sCand .size () : sCand .size () - 1 ; // sCand guaranteed to have size >= 1
873
+ size_t elementsToKeep = std::min (ef_construction_, size);
874
874
for (auto && cand : sCand ) {
875
875
if (cand == neigh)
876
876
continue ;
877
-
877
+
878
878
dist_t distance = fstdistfunc_ (getDataByInternalId (neigh), getDataByInternalId (cand), dist_func_param_);
879
879
if (candidates.size () < elementsToKeep) {
880
880
candidates.emplace (distance, cand);
@@ -893,7 +893,7 @@ namespace hnswlib {
893
893
std::unique_lock <std::mutex> lock (link_list_locks_[neigh]);
894
894
linklistsizeint *ll_cur;
895
895
ll_cur = get_linklist_at_level (neigh, layer);
896
- int candSize = candidates.size ();
896
+ size_t candSize = candidates.size ();
897
897
setListCount (ll_cur, candSize);
898
898
tableint *data = (tableint *) (ll_cur + 1 );
899
899
for (size_t idx = 0 ; idx < candSize; idx++) {
0 commit comments