Skip to content

Commit

Permalink
Fix label deletion from an unordered map - [MOD-6710] (#435)
Browse files Browse the repository at this point in the history
* fix

* another fix

* fix in BF as well

* format
GuyAv46 authored Feb 28, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 956e54f commit 0fca479
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/VecSim/algorithms/brute_force/brute_force_multi.h
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ int BruteForceIndex_Multi<DataType, DistType>::deleteVector(labelType label) {
}

// Deletes all vectors under the given label.
for (auto id_to_delete : deleted_label_ids_pair->second) {
for (auto &ids = deleted_label_ids_pair->second; idType id_to_delete : ids) {
this->removeVector(id_to_delete);
ret++;
}
8 changes: 4 additions & 4 deletions src/VecSim/algorithms/hnsw/hnsw_multi.h
Original file line number Diff line number Diff line change
@@ -176,15 +176,15 @@ template <typename DataType, typename DistType>
int HNSWIndex_Multi<DataType, DistType>::deleteVector(const labelType label) {
int ret = 0;
// check that the label actually exists in the graph, and update the number of elements.
auto ids = labelLookup.find(label);
if (ids == labelLookup.end()) {
auto ids_it = labelLookup.find(label);
if (ids_it == labelLookup.end()) {
return ret;
}
for (idType id : ids->second) {
for (auto &ids = ids_it->second; idType id : ids) {
this->removeVectorInPlace(id);
ret++;
}
labelLookup.erase(ids);
labelLookup.erase(label);
return ret;
}

0 comments on commit 0fca479

Please sign in to comment.