nmslib/hnswlib

int or tableint ?

Opened this issue · 0 comments

Hey there!

In both the searchBaseLayer() and searchBaseLayerST() functions in hnswalg.h, there is a part where neighbors of a vector are loaded, but it seems like there is a slight difference in their behaviors.

In the function searchBaseLayer() (line 274), the type of the vector's ID is defined as tableint (unsigned int):

image

However, in the function searchBaseLayerST() (line 378), it's defined as int:

image

After that, candidate_id is used to access visited_array. Since the vector ID is stored in memory as tableint (unsigned int), is there any possibility that a larger unsigned int could be converted to a negative number, causing issues like accessing visited_array[-1]?