From 3c77eda7ac2baa3b43cc3ecfbab34bb17c1ae62d Mon Sep 17 00:00:00 2001 From: yukun Date: Thu, 23 Sep 2021 18:59:54 +0800 Subject: [PATCH] Add error msgs in segcore (#8410) Signed-off-by: fishpenguin --- internal/core/src/query/SearchOnGrowing.cpp | 9 +++++---- internal/core/src/query/SearchOnSealed.cpp | 10 ++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/internal/core/src/query/SearchOnGrowing.cpp b/internal/core/src/query/SearchOnGrowing.cpp index 6e14af90bb..a279f29537 100644 --- a/internal/core/src/query/SearchOnGrowing.cpp +++ b/internal/core/src/query/SearchOnGrowing.cpp @@ -45,7 +45,7 @@ FloatSearch(const segcore::SegmentGrowingImpl& segment, auto vecfield_offset = info.field_offset_; auto& field = schema[vecfield_offset]; - Assert(field.get_data_type() == DataType::VECTOR_FLOAT); + AssertInfo(field.get_data_type() == DataType::VECTOR_FLOAT, "[FloatSearch]Field data type isn't VECTOR_FLOAT"); auto dim = field.get_dim(); auto topk = info.topk_; auto total_count = topk * num_queries; @@ -64,7 +64,8 @@ FloatSearch(const segcore::SegmentGrowingImpl& segment, auto max_indexed_id = indexing_record.get_finished_ack(); const auto& field_indexing = indexing_record.get_vec_field_indexing(vecfield_offset); auto search_conf = field_indexing.get_search_params(topk); - Assert(vec_ptr->get_size_per_chunk() == field_indexing.get_size_per_chunk()); + AssertInfo(vec_ptr->get_size_per_chunk() == field_indexing.get_size_per_chunk(), + "[FloatSearch]Chunk size of vector not equal to chunk size of field index"); for (int chunk_id = current_chunk_id; chunk_id < max_indexed_id; ++chunk_id) { auto size_per_chunk = field_indexing.get_size_per_chunk(); @@ -144,7 +145,7 @@ BinarySearch(const segcore::SegmentGrowingImpl& segment, auto vecfield_offset = info.field_offset_; auto& field = schema[vecfield_offset]; - Assert(field.get_data_type() == DataType::VECTOR_BINARY); + AssertInfo(field.get_data_type() == DataType::VECTOR_BINARY, "[BinarySearch]Field data type isn't VECTOR_BINARY"); auto dim = field.get_dim(); auto topk = info.topk_; auto total_count = topk * num_queries; @@ -197,7 +198,7 @@ SearchOnGrowing(const segcore::SegmentGrowingImpl& segment, SearchResult& results) { // TODO: add data_type to info auto data_type = segment.get_schema()[info.field_offset_].get_data_type(); - Assert(datatype_is_vector(data_type)); + AssertInfo(datatype_is_vector(data_type), "[SearchOnGrowing]Data type isn't vector type"); if (data_type == DataType::VECTOR_FLOAT) { auto typed_data = reinterpret_cast(query_data); FloatSearch(segment, info, typed_data, num_queries, ins_barrier, bitset, results); diff --git a/internal/core/src/query/SearchOnSealed.cpp b/internal/core/src/query/SearchOnSealed.cpp index 65fbd22cba..7b36d01eef 100644 --- a/internal/core/src/query/SearchOnSealed.cpp +++ b/internal/core/src/query/SearchOnSealed.cpp @@ -43,7 +43,7 @@ AssembleNegBitset(const BitsetSimple& bitset_simple) { auto acc_byte_count = 0; for (auto& bitset : bitset_simple) { auto size = bitset.size(); - Assert(size % 8 == 0); + AssertInfo(size % 8 == 0, "[AssembleNegBitset]Bitset size isn't times of 8"); auto byte_count = size / 8; auto src_ptr = boost_ext::get_data(bitset); memcpy(result.data() + acc_byte_count, src_ptr, byte_count); @@ -73,9 +73,10 @@ SearchOnSealed(const Schema& schema, // Assert(field.get_data_type() == DataType::VECTOR_FLOAT); auto dim = field.get_dim(); - Assert(record.is_ready(field_offset)); + AssertInfo(record.is_ready(field_offset), "[SearchOnSealed]Record isn't ready"); auto field_indexing = record.get_field_indexing(field_offset); - Assert(field_indexing->metric_type_ == search_info.metric_type_); + AssertInfo(field_indexing->metric_type_ == search_info.metric_type_, + "Metric type of field index isn't the same with search info"); auto final = [&] { auto ds = knowhere::GenDataset(num_queries, dim, query_data); @@ -85,7 +86,8 @@ SearchOnSealed(const Schema& schema, conf[milvus::knowhere::Metric::TYPE] = MetricTypeToName(field_indexing->metric_type_); auto index_type = field_indexing->indexing_->index_type(); auto adapter = milvus::knowhere::AdapterMgr::GetInstance().GetAdapter(index_type); - Assert(adapter->CheckSearch(conf, index_type, field_indexing->indexing_->index_mode())); + AssertInfo(adapter->CheckSearch(conf, index_type, field_indexing->indexing_->index_mode()), + "[SearchOnSealed]Search params check failed"); return field_indexing->indexing_->Query(ds, conf, bitset); }();