Skip to content

Commit 1e0e002

Browse files
authored
Merge pull request nmslib#311 from apoorv-sharma/master
Modify the hnsw update logic to unmark deleted element
2 parents 6300d58 + 1492527 commit 1e0e002

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,4 @@ To run test **with** updates (from `build` directory)
295295

296296
### References
297297

298-
Malkov, Yu A., and D. A. Yashunin. "Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs." TPAMI, preprint: https://arxiv.org/abs/1603.09320
298+
Malkov, Yu A., and D. A. Yashunin. "Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs." TPAMI, preprint: https://arxiv.org/abs/1603.09320

hnswlib/hnswalg.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,11 +981,15 @@ namespace hnswlib {
981981
auto search = label_lookup_.find(label);
982982
if (search != label_lookup_.end()) {
983983
tableint existingInternalId = search->second;
984-
985984
templock_curr.unlock();
986985

987986
std::unique_lock <std::mutex> lock_el_update(link_list_update_locks_[(existingInternalId & (max_update_element_locks - 1))]);
987+
988+
if (isMarkedDeleted(existingInternalId)) {
989+
unmarkDeletedInternal(existingInternalId);
990+
}
988991
updatePoint(data_point, existingInternalId, 1.0);
992+
989993
return existingInternalId;
990994
}
991995

0 commit comments

Comments
 (0)