From af54fd155b65db958eceebbe69b247d351194e8a Mon Sep 17 00:00:00 2001 From: "shengjun.li" Date: Fri, 26 Feb 2021 12:26:02 +0800 Subject: [PATCH] (1) fix Status destructor (#4745) (2) fix grpc-milvus URL (3) fix hnsw uninitialized variable Signed-off-by: shengjun.li --- core/src/index/thirdparty/hnswlib/hnswalg.h | 11 +++++------ core/src/utils/Status.cpp | 4 +++- sdk/cmake/ThirdPartyPackages.cmake | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/core/src/index/thirdparty/hnswlib/hnswalg.h b/core/src/index/thirdparty/hnswlib/hnswalg.h index d85455389b..9148f95e97 100644 --- a/core/src/index/thirdparty/hnswlib/hnswalg.h +++ b/core/src/index/thirdparty/hnswlib/hnswalg.h @@ -573,12 +573,9 @@ class HierarchicalNSW : public AlgorithmInterface { data_level0_memory_=data_level0_memory_new; // Reallocate all other layers - char ** linkLists_new = (char **) malloc(sizeof(void *) * new_max_elements); - if (linkLists_new == nullptr) + linkLists_ = (char **) realloc(linkLists_, sizeof(void *) * new_max_elements); + if (linkLists_ == nullptr) throw std::runtime_error("Not enough memory: resizeIndex failed to allocate other layers"); - memcpy(linkLists_new, linkLists_,cur_element_count * sizeof(void *)); - free(linkLists_); - linkLists_=linkLists_new; max_elements_=new_max_elements; @@ -1138,7 +1135,9 @@ class HierarchicalNSW : public AlgorithmInterface { ret += max_elements_ * size_data_per_element_; ret += max_elements_ * sizeof(void*); for (auto i = 0; i < max_elements_; ++ i) { - ret += linkLists_[i] ? size_links_per_element_ * element_levels_[i] : 0; + if (element_levels_[i] > 0) { + ret += size_links_per_element_ * element_levels_[i]; + } } return ret; } diff --git a/core/src/utils/Status.cpp b/core/src/utils/Status.cpp index a4f987bdf2..cd43bfaa54 100644 --- a/core/src/utils/Status.cpp +++ b/core/src/utils/Status.cpp @@ -34,7 +34,9 @@ Status::Status() : state_(nullptr) { } Status::~Status() { - delete state_; + if (state_ != nullptr) { + delete[] state_; + } } Status::Status(const Status& s) : state_(nullptr) { diff --git a/sdk/cmake/ThirdPartyPackages.cmake b/sdk/cmake/ThirdPartyPackages.cmake index 099cc4812a..2b5011ee52 100644 --- a/sdk/cmake/ThirdPartyPackages.cmake +++ b/sdk/cmake/ThirdPartyPackages.cmake @@ -185,7 +185,7 @@ if (DEFINED ENV{MILVUS_GRPC_URL}) set(GRPC_SOURCE_URL "$ENV{MILVUS_GRPC_URL}") else () set(GRPC_SOURCE_URL - "https://github.com/youny626/grpc-milvus/archive/master.zip") + "https://github.com/milvus-io/grpc-milvus/archive/master.zip") endif () if (DEFINED ENV{MILVUS_ZLIB_URL})