Skip to content

About interface #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
orrorcol opened this issue Sep 14, 2019 · 4 comments
Open

About interface #146

orrorcol opened this issue Sep 14, 2019 · 4 comments

Comments

@orrorcol
Copy link
Contributor

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 * .

void addPoint(void *data_point, labeltype label) {

  1. I think that searchKnn shuld first check if the "container" is empty, in wich case a search may result in a core dump.
    std::priority_queue<std::pair<dist_t, tableint>> searchKnnInternal(void *query_data, int k) {
@orrorcol
Copy link
Contributor Author

orrorcol commented Sep 14, 2019

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.

hnswlib/hnswlib/hnswalg.h

Lines 928 to 937 in 44f20f0

std::priority_queue<std::pair<dist_t, labeltype >> results;
while (top_candidates.size() > k) {
top_candidates.pop();
}
while (top_candidates.size() > 0) {
std::pair<dist_t, tableint> rez = top_candidates.top();
results.push(std::pair<dist_t, labeltype>(rez.first, getExternalLabel(rez.second)));
top_candidates.pop();
}
return results;

@yurymalkov
Copy link
Member

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

@orrorcol
Copy link
Contributor Author

Would you like some pull requests for these suggestions?

@yurymalkov
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants