nmslib / hnswlib

Header-only C++/python library for fast approximate nearest neighbors
https://github.com/nmslib/hnswlib
Apache License 2.0
4.11k stars 607 forks source link

Purpose of label_lookup_ #551

Open siddhsql opened 3 months ago

siddhsql commented 3 months ago

it seems there is a map in the code that stores mapping of external ids to internal ids in the variable labellookup.

std::unordered_map<labeltype, tableint> label_lookup_;

where:

https://github.com/nmslib/hnswlib/blob/master/hnswlib/hnswlib.h#L125:

typedef size_t labeltype;

https://github.com/nmslib/hnswlib/blob/master/hnswlib/hnswalg.h#L14:

typedef unsigned int tableint;

Why can't we use external ids for the internal ids as well? won't it remove unnecessary code and improve perf?

Arthur-Bi commented 3 months ago

labeltype can be a fix-size str