Skip to content

Commit 7db5671

Browse files
author
Dmitry Yashunin
committed
Refactoring
1 parent c750df8 commit 7db5671

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

hnswlib/hnswalg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
2020
static const unsigned char DELETE_MARK = 0x01;
2121

2222
size_t max_elements_{0};
23-
size_t cur_element_count{0};
23+
mutable std::atomic<size_t> cur_element_count{0}; // current number of elements
2424
size_t size_data_per_element_{0};
2525
size_t size_links_per_element_{0};
2626
mutable std::atomic<size_t> num_deleted_{0}; // number of deleted elements

python_bindings/bindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ PYBIND11_PLUGIN(hnswlib) {
10061006
return index.index_inited ? index.appr_alg->max_elements_ : 0;
10071007
})
10081008
.def_property_readonly("element_count", [](const Index<float> & index) {
1009-
return index.index_inited ? index.appr_alg->cur_element_count : 0;
1009+
return index.index_inited ? (size_t)index.appr_alg->cur_element_count : 0;
10101010
})
10111011
.def_property_readonly("ef_construction", [](const Index<float> & index) {
10121012
return index.index_inited ? index.appr_alg->ef_construction_ : 0;

0 commit comments

Comments
 (0)