diff --git a/hnswlib/hnswalg.h b/hnswlib/hnswalg.h index 8adaa591..5ba8cf0a 100644 --- a/hnswlib/hnswalg.h +++ b/hnswlib/hnswalg.h @@ -1181,6 +1181,26 @@ namespace hnswlib return; } + // Get all labels, segregated by deleted and non deleted. + std::pair, std::vector> getAllLabels() const + { + std::vector labels; + std::vector deleted_labels; + std::unique_lock 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 std::vector getDataByLabel(labeltype label) const {