diff --git a/internal/core/src/segcore/load_index_c.cpp b/internal/core/src/segcore/load_index_c.cpp index 11f4794595..7140bbec20 100644 --- a/internal/core/src/segcore/load_index_c.cpp +++ b/internal/core/src/segcore/load_index_c.cpp @@ -124,6 +124,12 @@ NewBinarySet(CBinarySet* c_binary_set) { } } +void +DeleteBinarySet(CBinarySet c_binary_set) { + auto binary_set = (milvus::knowhere::BinarySet*)c_binary_set; + delete binary_set; +} + CStatus AppendBinaryIndex(CBinarySet c_binary_set, void* index_binary, int64_t index_size, const char* c_index_key) { try { diff --git a/internal/core/src/segcore/load_index_c.h b/internal/core/src/segcore/load_index_c.h index 85df9c4079..9d1ce7928c 100644 --- a/internal/core/src/segcore/load_index_c.h +++ b/internal/core/src/segcore/load_index_c.h @@ -41,6 +41,9 @@ AppendIndex(CLoadIndexInfo c_load_index_info, CBinarySet c_binary_set); CStatus NewBinarySet(CBinarySet* c_binary_set); +void +DeleteBinarySet(CBinarySet c_binary_set); + CStatus AppendBinaryIndex(CBinarySet c_binary_set, void* index_binary, int64_t index_size, const char* c_index_key); diff --git a/internal/querynode/load_index_info.go b/internal/querynode/load_index_info.go index 8acae67217..e38fb6bd5b 100644 --- a/internal/querynode/load_index_info.go +++ b/internal/querynode/load_index_info.go @@ -73,6 +73,7 @@ func (li *LoadIndexInfo) appendFieldInfo(fieldID int64) error { func (li *LoadIndexInfo) appendIndex(bytesIndex [][]byte, indexKeys []string) error { var cBinarySet C.CBinarySet status := C.NewBinarySet(&cBinarySet) + defer C.DeleteBinarySet(cBinarySet) errorCode := status.error_code if errorCode != 0 {