From 5c997710ab5083e99e2cba681e4b827fcdf187ff Mon Sep 17 00:00:00 2001 From: yukun Date: Tue, 14 Sep 2021 10:06:40 +0800 Subject: [PATCH] Change Assert() to AssertInfo() to return error messages (#7843) Signed-off-by: fishpenguin --- internal/core/src/index/unittest/test_ivf_cpu_nm.cpp | 1 - internal/core/src/segcore/SegmentInterface.cpp | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/core/src/index/unittest/test_ivf_cpu_nm.cpp b/internal/core/src/index/unittest/test_ivf_cpu_nm.cpp index 708bc88371..f24eda1d32 100644 --- a/internal/core/src/index/unittest/test_ivf_cpu_nm.cpp +++ b/internal/core/src/index/unittest/test_ivf_cpu_nm.cpp @@ -127,7 +127,6 @@ TEST_P(IVFNMCPUTest, ivf_basic_cpu) { #ifdef MILVUS_GPU_VERSION milvus::knowhere::FaissGpuResourceMgr::GetInstance().Dump(); #endif - } TEST_P(IVFNMCPUTest, ivf_slice) { diff --git a/internal/core/src/segcore/SegmentInterface.cpp b/internal/core/src/segcore/SegmentInterface.cpp index ba0521ebbf..8886caab04 100644 --- a/internal/core/src/segcore/SegmentInterface.cpp +++ b/internal/core/src/segcore/SegmentInterface.cpp @@ -19,7 +19,8 @@ SegmentInternalInterface::FillTargetEntry(const query::Plan* plan, SearchResult& std::shared_lock lck(mutex_); AssertInfo(plan, "empty plan"); auto size = results.result_distances_.size(); - Assert(results.internal_seg_offsets_.size() == size); + AssertInfo(results.internal_seg_offsets_.size() == size, + "Size of result distances is not equal to size of segment offsets"); // Assert(results.result_offsets_.size() == size); Assert(results.row_data_.size() == 0); @@ -34,9 +35,10 @@ SegmentInternalInterface::FillTargetEntry(const query::Plan* plan, SearchResult& bulk_subscript(SystemFieldType::RowId, results.internal_seg_offsets_.data(), size, blob.data()); } else { auto key_offset_opt = get_schema().get_primary_key_offset(); - Assert(key_offset_opt.has_value()); + AssertInfo(key_offset_opt.has_value(), "Cannot get primary key offset from schema"); auto key_offset = key_offset_opt.value(); - Assert(get_schema()[key_offset].get_data_type() == DataType::INT64); + AssertInfo(get_schema()[key_offset].get_data_type() == DataType::INT64, + "Primary key field is not INT64 type"); bulk_subscript(key_offset, results.internal_seg_offsets_.data(), size, blob.data()); } blobs.emplace_back(std::move(blob)); @@ -161,7 +163,7 @@ CreateDataArrayFrom(const void* data_raw, int64_t count, const FieldMeta& field_ break; } case DataType::VECTOR_BINARY: { - Assert(dim % 8 == 0); + AssertInfo(dim % 8 == 0, "Binary vector field dimension is not a multiple of 8"); auto num_bytes = count * dim / 8; auto data = reinterpret_cast(data_raw); auto obj = vector_array->mutable_binary_vector();