Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Yashunin committed Nov 27, 2022
1 parent c750df8 commit ef7e383
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hnswlib/hnswalg.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
static const unsigned char DELETE_MARK = 0x01;

size_t max_elements_{0};
size_t cur_element_count{0};
mutable std::atomic<size_t> cur_element_count{0}; // current number of elements
size_t size_data_per_element_{0};
size_t size_links_per_element_{0};
mutable std::atomic<size_t> num_deleted_{0}; // number of deleted elements
Expand Down
4 changes: 2 additions & 2 deletions python_bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ class Index {
return py::dict(
"offset_level0"_a = appr_alg->offsetLevel0_,
"max_elements"_a = appr_alg->max_elements_,
"cur_element_count"_a = appr_alg->cur_element_count,
"cur_element_count"_a = (size_t)appr_alg->cur_element_count,
"size_data_per_element"_a = appr_alg->size_data_per_element_,
"label_offset"_a = appr_alg->label_offset_,
"offset_data"_a = appr_alg->offsetData_,
Expand Down Expand Up @@ -1006,7 +1006,7 @@ PYBIND11_PLUGIN(hnswlib) {
return index.index_inited ? index.appr_alg->max_elements_ : 0;
})
.def_property_readonly("element_count", [](const Index<float> & index) {
return index.index_inited ? index.appr_alg->cur_element_count : 0;
return index.index_inited ? (size_t)index.appr_alg->cur_element_count : 0;
})
.def_property_readonly("ef_construction", [](const Index<float> & index) {
return index.index_inited ? index.appr_alg->ef_construction_ : 0;
Expand Down

0 comments on commit ef7e383

Please sign in to comment.