hnswlib icon indicating copy to clipboard operation
hnswlib copied to clipboard

About interface

Open orrorcol opened this issue 5 years ago • 4 comments

I'm integrating hnswlib into my own code, I have the following suggestions:

  1. I think that the data passed to addPoint should be const void * .

https://github.com/nmslib/hnswlib/blob/44f20f0b2257af1b3251ac9ed976a6d6583967c0/hnswlib/hnswalg.h#L773

  1. I think that searchKnn shuld first check if the "container" is empty, in wich case a search may result in a core dump. https://github.com/nmslib/hnswlib/blob/44f20f0b2257af1b3251ac9ed976a6d6583967c0/hnswlib/hnswalg.h#L486

orrorcol avatar Sep 14 '19 05:09 orrorcol

Another suggestion: the result points are aranged in a max heap, while what people interested in is the nearest points. I would suggest using another comparator that would return a min heap. https://github.com/nmslib/hnswlib/blob/44f20f0b2257af1b3251ac9ed976a6d6583967c0/hnswlib/hnswalg.h#L928-L937

orrorcol avatar Sep 14 '19 12:09 orrorcol

@uestc-lfs Thanks for the suggestions! Seems reasonable.

yurymalkov avatar Sep 16 '19 11:09 yurymalkov

Would you like some pull requests for these suggestions?

orrorcol avatar Sep 24 '19 06:09 orrorcol

@uestc-lfs Yeah, sure. That would be great! I've already started to implement them, but was distracted by other things...

yurymalkov avatar Sep 24 '19 20:09 yurymalkov