Skip to content

Commit d18f804

Browse files
authored
Merge pull request #163 from vimal-mathew/develop
Expose current-count and max-elements in Python
2 parents 5ad84a1 + a8a0bed commit d18f804

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

python_bindings/bindings.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,14 @@ class Index {
359359
appr_alg->resizeIndex(new_size);
360360
}
361361

362+
size_t getMaxElements() const {
363+
return appr_alg->max_elements_;
364+
}
365+
366+
size_t getCurrentCount() const {
367+
return appr_alg->cur_element_count;
368+
}
369+
362370
std::string space_name;
363371
int dim;
364372

@@ -397,6 +405,8 @@ PYBIND11_PLUGIN(hnswlib) {
397405
.def("load_index", &Index<float>::loadIndex, py::arg("path_to_index"), py::arg("max_elements")=0)
398406
.def("mark_deleted", &Index<float>::markDeleted, py::arg("label"))
399407
.def("resize_index", &Index<float>::resizeIndex, py::arg("new_size"))
408+
.def("get_max_elements", &Index<float>::getMaxElements)
409+
.def("get_current_count", &Index<float>::getCurrentCount)
400410
.def("__repr__",
401411
[](const Index<float> &a) {
402412
return "<HNSW-lib index>";

0 commit comments

Comments
 (0)