Skip to content

Commit

Permalink
Add API for listing all nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
sanketkedia committed Nov 24, 2024
1 parent 1aaa5e1 commit 955b5a0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions hnswlib/hnswalg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,26 @@ namespace hnswlib
return;
}

// Get all labels, segregated by deleted and non deleted.
std::pair<std::vector<labeltype>, std::vector<labeltype>> getAllLabels() const
{
std::vector<labeltype> labels;
std::vector<labeltype> deleted_labels;
std::unique_lock<std::mutex> label_lock(label_lookup_lock);
for (auto it = label_lookup_.begin(); it != label_lookup_.end(); ++it)
{
if (!isMarkedDeleted(it->second))
{
labels.push_back(it->first);
}
else
{
deleted_labels.push_back(it->first);
}
}
return std::make_pair(labels, deleted_labels);
}

template <typename data_t>
std::vector<data_t> getDataByLabel(labeltype label) const
{
Expand Down

0 comments on commit 955b5a0

Please sign in to comment.