Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 0.6.2 to master #371

Merged
merged 7 commits into from
Feb 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix uint32 overflow
  • Loading branch information
yurymalkov committed Feb 12, 2022
commit 010dfcbba86d3c226a1771a70f8b9fa9b7b03a1d
18 changes: 9 additions & 9 deletions python_bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ class Index {
py::dict getAnnData() const { /* WARNING: Index::getAnnData is not thread-safe with Index::addItems */
std::unique_lock <std::mutex> templock(appr_alg->global);

unsigned int level0_npy_size = appr_alg->cur_element_count * appr_alg->size_data_per_element_;
unsigned int link_npy_size = 0;
std::vector<unsigned int> link_npy_offsets(appr_alg->cur_element_count);
size_t level0_npy_size = appr_alg->cur_element_count * appr_alg->size_data_per_element_;
size_t link_npy_size = 0;
std::vector<size_t> link_npy_offsets(appr_alg->cur_element_count);

for (size_t i = 0; i < appr_alg->cur_element_count; i++){
unsigned int linkListSize = appr_alg->element_levels_[i] > 0 ? appr_alg->size_links_per_element_ * appr_alg->element_levels_[i] : 0;
size_t linkListSize = appr_alg->element_levels_[i] > 0 ? appr_alg->size_links_per_element_ * appr_alg->element_levels_[i] : 0;
link_npy_offsets[i]=link_npy_size;
if (linkListSize)
link_npy_size += linkListSize;
Expand Down Expand Up @@ -326,7 +326,7 @@ class Index {
memcpy(element_levels_npy, appr_alg->element_levels_.data(), appr_alg->element_levels_.size() * sizeof(int));

for (size_t i = 0; i < appr_alg->cur_element_count; i++){
unsigned int linkListSize = appr_alg->element_levels_[i] > 0 ? appr_alg->size_links_per_element_ * appr_alg->element_levels_[i] : 0;
size_t linkListSize = appr_alg->element_levels_[i] > 0 ? appr_alg->size_links_per_element_ * appr_alg->element_levels_[i] : 0;
if (linkListSize){
memcpy(link_list_npy+link_npy_offsets[i], appr_alg->linkLists_[i], linkListSize);
}
Expand Down Expand Up @@ -500,11 +500,11 @@ class Index {

memcpy(appr_alg->element_levels_.data(), element_levels_npy.data(), element_levels_npy.nbytes());

unsigned int link_npy_size = 0;
std::vector<unsigned int> link_npy_offsets(appr_alg->cur_element_count);
size_t link_npy_size = 0;
std::vector<size_t> link_npy_offsets(appr_alg->cur_element_count);

for (size_t i = 0; i < appr_alg->cur_element_count; i++){
unsigned int linkListSize = appr_alg->element_levels_[i] > 0 ? appr_alg->size_links_per_element_ * appr_alg->element_levels_[i] : 0;
size_t linkListSize = appr_alg->element_levels_[i] > 0 ? appr_alg->size_links_per_element_ * appr_alg->element_levels_[i] : 0;
link_npy_offsets[i]=link_npy_size;
if (linkListSize)
link_npy_size += linkListSize;
Expand All @@ -513,7 +513,7 @@ class Index {
memcpy(appr_alg->data_level0_memory_, data_level0_npy.data(), data_level0_npy.nbytes());

for (size_t i = 0; i < appr_alg->max_elements_; i++) {
unsigned int linkListSize = appr_alg->element_levels_[i] > 0 ? appr_alg->size_links_per_element_ * appr_alg->element_levels_[i] : 0;
size_t linkListSize = appr_alg->element_levels_[i] > 0 ? appr_alg->size_links_per_element_ * appr_alg->element_levels_[i] : 0;
if (linkListSize == 0) {
appr_alg->linkLists_[i] = nullptr;
} else {
Expand Down