diff --git a/internal/core/src/common/Array.h b/internal/core/src/common/Array.h index 093936b4c1924..77b4d16cd44d7 100644 --- a/internal/core/src/common/Array.h +++ b/internal/core/src/common/Array.h @@ -227,8 +227,7 @@ class Array { return true; } default: - PanicCodeInfo(Unsupported, - "unsupported element type for array"); + PanicInfo(Unsupported, "unsupported element type for array"); } } @@ -264,8 +263,8 @@ class Array { return static_cast( reinterpret_cast(data_)[index]); default: - PanicCodeInfo(Unsupported, - "unsupported element type for array"); + PanicInfo(Unsupported, + "unsupported element type for array"); } } return reinterpret_cast(data_)[index]; @@ -481,8 +480,8 @@ class ArrayView { return static_cast( reinterpret_cast(data_)[index]); default: - PanicCodeInfo(Unsupported, - "unsupported element type for array"); + PanicInfo(Unsupported, + "unsupported element type for array"); } } return reinterpret_cast(data_)[index]; diff --git a/internal/core/src/common/EasyAssert.h b/internal/core/src/common/EasyAssert.h index b468759a7ab41..07a444c4a70b9 100644 --- a/internal/core/src/common/EasyAssert.h +++ b/internal/core/src/common/EasyAssert.h @@ -53,6 +53,8 @@ enum ErrorCode { DataFormatBroken = 2024, JsonKeyInvalid = 2025, MetricTypeInvalid = 2026, + FieldNotLoaded = 2027, + ExprInvalid = 2028, UnistdError = 2030, KnowhereError = 2100, }; @@ -71,7 +73,7 @@ class SegcoreError : public std::runtime_error { public: static SegcoreError success() { - return SegcoreError(ErrorCode::Success, ""); + return {ErrorCode::Success, ""}; } SegcoreError(ErrorCode error_code, const std::string& error_msg) @@ -125,13 +127,8 @@ FailureCStatus(std::exception* ex) { } while (0) #define Assert(expr) AssertInfo((expr), "") -#define PanicInfo(info) \ - do { \ - milvus::impl::EasyAssertInfo(false, "", __FILE__, __LINE__, (info)); \ - __builtin_unreachable(); \ - } while (0) -#define PanicCodeInfo(errcode, info) \ +#define PanicInfo(errcode, info) \ do { \ milvus::impl::EasyAssertInfo( \ false, "", __FILE__, __LINE__, (info), errcode); \ diff --git a/internal/core/src/common/FieldMeta.h b/internal/core/src/common/FieldMeta.h index 4cf555a3ce876..c6d1775595068 100644 --- a/internal/core/src/common/FieldMeta.h +++ b/internal/core/src/common/FieldMeta.h @@ -95,9 +95,8 @@ datatype_name(DataType data_type) { return "vector_float16"; } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("Unsupported DataType({})", - fmt::underlying(data_type))); + PanicInfo(DataTypeInvalid, + fmt::format("Unsupported DataType({})", data_type)); } } } diff --git a/internal/core/src/common/SystemProperty.h b/internal/core/src/common/SystemProperty.h index b0aac7fcb6383..65800aea38dbf 100644 --- a/internal/core/src/common/SystemProperty.h +++ b/internal/core/src/common/SystemProperty.h @@ -18,7 +18,7 @@ #include -#include "Types.h" +#include "common/Types.h" namespace milvus { @@ -63,3 +63,23 @@ class SystemProperty { }; } // namespace milvus + +template <> +struct fmt::formatter : formatter { + auto + format(milvus::SystemFieldType c, format_context& ctx) const { + string_view name = "unknown"; + switch (c) { + case milvus::SystemFieldType::Invalid: + name = "Invalid"; + break; + case milvus::SystemFieldType::RowId: + name = "RowId"; + break; + case milvus::SystemFieldType::Timestamp: + name = "Timestamp"; + break; + } + return formatter::format(name, ctx); + } +}; diff --git a/internal/core/src/common/Types.h b/internal/core/src/common/Types.h index 1a16d8825f2dd..2db86a0390002 100644 --- a/internal/core/src/common/Types.h +++ b/internal/core/src/common/Types.h @@ -35,6 +35,7 @@ #include #include +#include "fmt/core.h" #include "knowhere/binaryset.h" #include "knowhere/comp/index_param.h" #include "knowhere/dataset.h" @@ -238,3 +239,59 @@ struct fmt::formatter : formatter { return formatter::format(name, ctx); } }; + +template <> +struct fmt::formatter : formatter { + auto + format(milvus::OpType c, format_context& ctx) const { + string_view name = "unknown"; + switch (c) { + case milvus::OpType::Invalid: + name = "Invalid"; + break; + case milvus::OpType::GreaterThan: + name = "GreaterThan"; + break; + case milvus::OpType::GreaterEqual: + name = "GreaterEqual"; + break; + case milvus::OpType::LessThan: + name = "LessThan"; + break; + case milvus::OpType::LessEqual: + name = "LessEqual"; + break; + case milvus::OpType::Equal: + name = "Equal"; + break; + case milvus::OpType::NotEqual: + name = "NotEqual"; + break; + case milvus::OpType::PrefixMatch: + name = "PrefixMatch"; + break; + case milvus::OpType::PostfixMatch: + name = "PostfixMatch"; + break; + case milvus::OpType::Match: + name = "Match"; + break; + case milvus::OpType::Range: + name = "Range"; + break; + case milvus::OpType::In: + name = "In"; + break; + case milvus::OpType::NotIn: + name = "NotIn"; + break; + case milvus::OpType::OpType_INT_MIN_SENTINEL_DO_NOT_USE_: + name = "OpType_INT_MIN_SENTINEL_DO_NOT_USE"; + break; + case milvus::OpType::OpType_INT_MAX_SENTINEL_DO_NOT_USE_: + name = "OpType_INT_MAX_SENTINEL_DO_NOT_USE"; + break; + } + return formatter::format(name, ctx); + } +}; diff --git a/internal/core/src/config/ConfigKnowhere.cpp b/internal/core/src/config/ConfigKnowhere.cpp index 269d8b4911ae5..cfe235876221c 100644 --- a/internal/core/src/config/ConfigKnowhere.cpp +++ b/internal/core/src/config/ConfigKnowhere.cpp @@ -62,13 +62,13 @@ KnowhereSetSimdType(const char* value) { } else if (strcmp(value, "avx") == 0 || strcmp(value, "sse4_2") == 0) { simd_type = knowhere::KnowhereConfig::SimdType::SSE4_2; } else { - PanicInfo("invalid SIMD type: " + std::string(value)); + PanicInfo(ConfigInvalid, "invalid SIMD type: " + std::string(value)); } try { return knowhere::KnowhereConfig::SetSimdType(simd_type); } catch (std::exception& e) { LOG_SERVER_ERROR_ << e.what(); - PanicInfo(e.what()); + PanicInfo(ConfigInvalid, e.what()); } } @@ -81,8 +81,9 @@ void KnowhereInitSearchThreadPool(const uint32_t num_threads) { knowhere::KnowhereConfig::SetSearchThreadPoolSize(num_threads); if (!knowhere::KnowhereConfig::SetAioContextPool(num_threads)) { - PanicInfo("Failed to set aio context pool with num_threads " + - std::to_string(num_threads)); + PanicInfo(ConfigInvalid, + "Failed to set aio context pool with num_threads " + + std::to_string(num_threads)); } } diff --git a/internal/core/src/index/ScalarIndex-inl.h b/internal/core/src/index/ScalarIndex-inl.h index 3410e9dc83439..b59aadf27d47f 100644 --- a/internal/core/src/index/ScalarIndex-inl.h +++ b/internal/core/src/index/ScalarIndex-inl.h @@ -64,9 +64,9 @@ ScalarIndex::Query(const DatasetPtr& dataset) { case OpType::PrefixMatch: case OpType::PostfixMatch: default: - throw SegcoreError(OpTypeInvalid, - fmt::format("unsupported operator type: {}", - fmt::underlying(op))); + throw SegcoreError( + OpTypeInvalid, + fmt::format("unsupported operator type: {}", op)); } } diff --git a/internal/core/src/index/ScalarIndex.h b/internal/core/src/index/ScalarIndex.h index f7dbc2f736bbe..3fb4c27425615 100644 --- a/internal/core/src/index/ScalarIndex.h +++ b/internal/core/src/index/ScalarIndex.h @@ -39,8 +39,8 @@ class ScalarIndex : public IndexBase { void BuildWithDataset(const DatasetPtr& dataset, const Config& config = {}) override { - PanicCodeInfo(Unsupported, - "scalar index don't support build index with dataset"); + PanicInfo(Unsupported, + "scalar index don't support build index with dataset"); }; public: diff --git a/internal/core/src/index/ScalarIndexSort-inl.h b/internal/core/src/index/ScalarIndexSort-inl.h index a21c6c4b918f4..cc3fb604f8af4 100644 --- a/internal/core/src/index/ScalarIndexSort-inl.h +++ b/internal/core/src/index/ScalarIndexSort-inl.h @@ -24,6 +24,7 @@ #include "Meta.h" #include "common/Utils.h" #include "common/Slice.h" +#include "common/Types.h" #include "index/Utils.h" namespace milvus::index { @@ -253,9 +254,8 @@ ScalarIndexSort::Range(const T value, const OpType op) { data_.begin(), data_.end(), IndexStructure(value)); break; default: - throw SegcoreError( - OpTypeInvalid, - fmt::format("Invalid OperatorType: {}", fmt::underlying(op))); + throw SegcoreError(OpTypeInvalid, + fmt::format("Invalid OperatorType: {}", op)); } for (; lb < ub; ++lb) { bitset[lb->idx_] = true; diff --git a/internal/core/src/index/VectorDiskIndex.cpp b/internal/core/src/index/VectorDiskIndex.cpp index 195c0a6e701a6..10b272f13fb0b 100644 --- a/internal/core/src/index/VectorDiskIndex.cpp +++ b/internal/core/src/index/VectorDiskIndex.cpp @@ -80,9 +80,8 @@ VectorDiskAnnIndex::Load(const Config& config) { auto stat = index_.Deserialize(knowhere::BinarySet(), load_config); if (stat != knowhere::Status::success) - PanicCodeInfo( - ErrorCode::UnexpectedError, - "failed to Deserialize index, " + KnowhereStatusString(stat)); + PanicInfo(ErrorCode::UnexpectedError, + "failed to Deserialize index, " + KnowhereStatusString(stat)); SetDim(index_.Dim()); } @@ -185,8 +184,8 @@ VectorDiskAnnIndex::BuildWithDataset(const DatasetPtr& dataset, knowhere::DataSet* ds_ptr = nullptr; auto stat = index_.Build(*ds_ptr, build_config); if (stat != knowhere::Status::success) - PanicCodeInfo(ErrorCode::IndexBuildError, - "failed to build index, " + KnowhereStatusString(stat)); + PanicInfo(ErrorCode::IndexBuildError, + "failed to build index, " + KnowhereStatusString(stat)); local_chunk_manager->RemoveDir( storage::GetSegmentRawDataPathPrefix(local_chunk_manager, segment_id)); @@ -243,20 +242,20 @@ VectorDiskAnnIndex::Query(const DatasetPtr dataset, auto res = index_.RangeSearch(*dataset, search_config, bitset); if (!res.has_value()) { - PanicCodeInfo(ErrorCode::UnexpectedError, - fmt::format("failed to range search: {}: {}", - KnowhereStatusString(res.error()), - res.what())); + PanicInfo(ErrorCode::UnexpectedError, + fmt::format("failed to range search: {}: {}", + KnowhereStatusString(res.error()), + res.what())); } return ReGenRangeSearchResult( res.value(), topk, num_queries, GetMetricType()); } else { auto res = index_.Search(*dataset, search_config, bitset); if (!res.has_value()) { - PanicCodeInfo(ErrorCode::UnexpectedError, - fmt::format("failed to search: {}: {}", - KnowhereStatusString(res.error()), - res.what())); + PanicInfo(ErrorCode::UnexpectedError, + fmt::format("failed to search: {}: {}", + KnowhereStatusString(res.error()), + res.what())); } return res.value(); } @@ -298,10 +297,10 @@ std::vector VectorDiskAnnIndex::GetVector(const DatasetPtr dataset) const { auto res = index_.GetVectorByIds(*dataset); if (!res.has_value()) { - PanicCodeInfo(ErrorCode::UnexpectedError, - fmt::format("failed to get vector: {}: {}", - KnowhereStatusString(res.error()), - res.what())); + PanicInfo(ErrorCode::UnexpectedError, + fmt::format("failed to get vector: {}: {}", + KnowhereStatusString(res.error()), + res.what())); } auto index_type = GetIndexType(); auto tensor = res.value()->GetTensor(); diff --git a/internal/core/src/index/VectorIndex.h b/internal/core/src/index/VectorIndex.h index 3bd3948f04e99..6c906c02f655a 100644 --- a/internal/core/src/index/VectorIndex.h +++ b/internal/core/src/index/VectorIndex.h @@ -45,14 +45,13 @@ class VectorIndex : public IndexBase { BuildWithRawData(size_t n, const void* values, const Config& config = {}) override { - PanicCodeInfo(Unsupported, - "vector index don't support build index with raw data"); + PanicInfo(Unsupported, + "vector index don't support build index with raw data"); }; virtual void AddWithDataset(const DatasetPtr& dataset, const Config& config) { - PanicCodeInfo(Unsupported, - "vector index don't support add with dataset"); + PanicInfo(Unsupported, "vector index don't support add with dataset"); } virtual std::unique_ptr diff --git a/internal/core/src/index/VectorMemIndex.cpp b/internal/core/src/index/VectorMemIndex.cpp index 59d268d35d3ea..f00e9a2c7e327 100644 --- a/internal/core/src/index/VectorMemIndex.cpp +++ b/internal/core/src/index/VectorMemIndex.cpp @@ -84,9 +84,8 @@ VectorMemIndex::Serialize(const Config& config) { knowhere::BinarySet ret; auto stat = index_.Serialize(ret); if (stat != knowhere::Status::success) - PanicCodeInfo( - ErrorCode::UnexpectedError, - "failed to serialize index, " + KnowhereStatusString(stat)); + PanicInfo(ErrorCode::UnexpectedError, + "failed to serialize index, " + KnowhereStatusString(stat)); Disassemble(ret); return ret; @@ -97,9 +96,8 @@ VectorMemIndex::LoadWithoutAssemble(const BinarySet& binary_set, const Config& config) { auto stat = index_.Deserialize(binary_set, config); if (stat != knowhere::Status::success) - PanicCodeInfo( - ErrorCode::UnexpectedError, - "failed to Deserialize index, " + KnowhereStatusString(stat)); + PanicInfo(ErrorCode::UnexpectedError, + "failed to Deserialize index, " + KnowhereStatusString(stat)); SetDim(index_.Dim()); } @@ -231,8 +229,8 @@ VectorMemIndex::BuildWithDataset(const DatasetPtr& dataset, knowhere::TimeRecorder rc("BuildWithoutIds", 1); auto stat = index_.Build(*dataset, index_config); if (stat != knowhere::Status::success) - PanicCodeInfo(ErrorCode::IndexBuildError, - "failed to build index, " + KnowhereStatusString(stat)); + PanicInfo(ErrorCode::IndexBuildError, + "failed to build index, " + KnowhereStatusString(stat)); rc.ElapseFromBegin("Done"); SetDim(index_.Dim()); } @@ -283,8 +281,8 @@ VectorMemIndex::AddWithDataset(const DatasetPtr& dataset, knowhere::TimeRecorder rc("AddWithDataset", 1); auto stat = index_.Add(*dataset, index_config); if (stat != knowhere::Status::success) - PanicCodeInfo(ErrorCode::IndexBuildError, - "failed to append index, " + KnowhereStatusString(stat)); + PanicInfo(ErrorCode::IndexBuildError, + "failed to append index, " + KnowhereStatusString(stat)); rc.ElapseFromBegin("Done"); } @@ -313,10 +311,10 @@ VectorMemIndex::Query(const DatasetPtr dataset, auto res = index_.RangeSearch(*dataset, search_conf, bitset); milvus::tracer::AddEvent("finish_knowhere_index_range_search"); if (!res.has_value()) { - PanicCodeInfo(ErrorCode::UnexpectedError, - fmt::format("failed to range search: {}: {}", - KnowhereStatusString(res.error()), - res.what())); + PanicInfo(ErrorCode::UnexpectedError, + fmt::format("failed to range search: {}: {}", + KnowhereStatusString(res.error()), + res.what())); } auto result = ReGenRangeSearchResult( res.value(), topk, num_queries, GetMetricType()); @@ -327,10 +325,10 @@ VectorMemIndex::Query(const DatasetPtr dataset, auto res = index_.Search(*dataset, search_conf, bitset); milvus::tracer::AddEvent("finish_knowhere_index_search"); if (!res.has_value()) { - PanicCodeInfo(ErrorCode::UnexpectedError, - fmt::format("failed to search: {}: {}", - KnowhereStatusString(res.error()), - res.what())); + PanicInfo(ErrorCode::UnexpectedError, + fmt::format("failed to search: {}: {}", + KnowhereStatusString(res.error()), + res.what())); } return res.value(); } @@ -369,9 +367,8 @@ std::vector VectorMemIndex::GetVector(const DatasetPtr dataset) const { auto res = index_.GetVectorByIds(*dataset); if (!res.has_value()) { - PanicCodeInfo( - ErrorCode::UnexpectedError, - "failed to get vector, " + KnowhereStatusString(res.error())); + PanicInfo(ErrorCode::UnexpectedError, + "failed to get vector, " + KnowhereStatusString(res.error())); } auto index_type = GetIndexType(); auto tensor = res.value()->GetTensor(); @@ -489,9 +486,9 @@ VectorMemIndex::LoadFromFile(const Config& config) { conf[kEnableMmap] = true; auto stat = index_.DeserializeFromFile(filepath.value(), conf); if (stat != knowhere::Status::success) { - PanicCodeInfo(ErrorCode::UnexpectedError, - fmt::format("failed to Deserialize index: {}", - KnowhereStatusString(stat))); + PanicInfo(ErrorCode::UnexpectedError, + fmt::format("failed to Deserialize index: {}", + KnowhereStatusString(stat))); } auto dim = index_.Dim(); diff --git a/internal/core/src/mmap/Utils.h b/internal/core/src/mmap/Utils.h index 2be998ac2da2a..e3b718e766a3f 100644 --- a/internal/core/src/mmap/Utils.h +++ b/internal/core/src/mmap/Utils.h @@ -66,8 +66,8 @@ FillField(DataType data_type, const storage::FieldDataPtr data, void* dst) { break; } default: - PanicInfo(fmt::format("not supported data type {}", - datatype_name(data_type))); + PanicInfo(DataTypeInvalid, + fmt::format("not supported data type {}", data_type)); } } else { memcpy(dst, data->Data(), data->Size()); @@ -125,7 +125,8 @@ WriteFieldData(File& file, break; } default: - PanicInfo(fmt::format("not supported data type {}", + PanicInfo(DataTypeInvalid, + fmt::format("not supported data type {}", datatype_name(data_type))); } } else { diff --git a/internal/core/src/query/Expr.h b/internal/core/src/query/Expr.h index 839e10a3e036a..93a52f0076c3c 100644 --- a/internal/core/src/query/Expr.h +++ b/internal/core/src/query/Expr.h @@ -310,3 +310,50 @@ IsTermExpr(Expr* expr) { } } // namespace milvus::query + +template <> +struct fmt::formatter + : formatter { + auto + format(milvus::query::LogicalUnaryExpr::OpType c, + format_context& ctx) const { + string_view name = "unknown"; + switch (c) { + case milvus::query::LogicalUnaryExpr::OpType::Invalid: + name = "Invalid"; + break; + case milvus::query::LogicalUnaryExpr::OpType::LogicalNot: + name = "LogicalNot"; + break; + } + return formatter::format(name, ctx); + } +}; + +template <> +struct fmt::formatter + : formatter { + auto + format(milvus::query::LogicalBinaryExpr::OpType c, + format_context& ctx) const { + string_view name = "unknown"; + switch (c) { + case milvus::query::LogicalBinaryExpr::OpType::Invalid: + name = "Invalid"; + break; + case milvus::query::LogicalBinaryExpr::OpType::LogicalAnd: + name = "LogicalAdd"; + break; + case milvus::query::LogicalBinaryExpr::OpType::LogicalOr: + name = "LogicalOr"; + break; + case milvus::query::LogicalBinaryExpr::OpType::LogicalXor: + name = "LogicalXor"; + break; + case milvus::query::LogicalBinaryExpr::OpType::LogicalMinus: + name = "LogicalMinus"; + break; + } + return formatter::format(name, ctx); + } +}; diff --git a/internal/core/src/query/PlanProto.cpp b/internal/core/src/query/PlanProto.cpp index ae8013f37b6c9..021fece0ce08f 100644 --- a/internal/core/src/query/PlanProto.cpp +++ b/internal/core/src/query/PlanProto.cpp @@ -339,12 +339,13 @@ ProtoParser::ParseUnaryRangeExpr(const proto::plan::UnaryRangeExpr& expr_pb) { field_id, data_type, expr_pb); default: PanicInfo( + DataTypeInvalid, fmt::format("unknown data type: {} in expression", expr_pb.value().val_case())); } } default: { - PanicInfo("unsupported data type"); + PanicInfo(DataTypeInvalid, "unsupported data type"); } } }(); @@ -401,7 +402,10 @@ ProtoParser::ParseBinaryRangeExpr(const proto::plan::BinaryRangeExpr& expr_pb) { return ExtractBinaryRangeExprImpl( field_id, data_type, expr_pb); default: - PanicInfo("unknown data type in expression"); + PanicInfo( + DataTypeInvalid, + fmt::format("unknown data type in expression {}", + data_type)); } } case DataType::ARRAY: { @@ -416,12 +420,16 @@ ProtoParser::ParseBinaryRangeExpr(const proto::plan::BinaryRangeExpr& expr_pb) { return ExtractBinaryRangeExprImpl( field_id, data_type, expr_pb); default: - PanicInfo("unknown data type in expression"); + PanicInfo( + DataTypeInvalid, + fmt::format("unknown data type in expression {}", + data_type)); } } default: { - PanicInfo("unsupported data type"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", data_type)); } } }(); @@ -513,6 +521,7 @@ ProtoParser::ParseTermExpr(const proto::plan::TermExpr& expr_pb) { field_id, data_type, expr_pb); default: PanicInfo( + DataTypeInvalid, fmt::format("unknown data type: {} in expression", expr_pb.values()[0].val_case())); } @@ -537,12 +546,14 @@ ProtoParser::ParseTermExpr(const proto::plan::TermExpr& expr_pb) { field_id, data_type, expr_pb); default: PanicInfo( + DataTypeInvalid, fmt::format("unknown data type: {} in expression", expr_pb.values()[0].val_case())); } } default: { - PanicInfo("unsupported data type"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", data_type)); } } }(); @@ -601,9 +612,10 @@ ProtoParser::ParseBinaryArithOpEvalRangeExpr( return ExtractBinaryArithOpEvalRangeExprImpl( field_id, data_type, expr_pb); default: - PanicInfo(fmt::format( - "unsupported data type {} in expression", - expr_pb.value().val_case())); + PanicInfo(DataTypeInvalid, + fmt::format( + "unsupported data type {} in expression", + expr_pb.value().val_case())); } } case DataType::ARRAY: { @@ -615,13 +627,15 @@ ProtoParser::ParseBinaryArithOpEvalRangeExpr( return ExtractBinaryArithOpEvalRangeExprImpl( field_id, data_type, expr_pb); default: - PanicInfo(fmt::format( - "unsupported data type {} in expression", - expr_pb.value().val_case())); + PanicInfo(DataTypeInvalid, + fmt::format( + "unsupported data type {} in expression", + expr_pb.value().val_case())); } } default: { - PanicInfo("unsupported data type"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", data_type)); } } }(); @@ -646,7 +660,8 @@ ProtoParser::ParseExistExpr(const proto::plan::ExistsExpr& expr_pb) { return ExtractExistsExprImpl(expr_pb); } default: { - PanicInfo("unsupported data type"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", data_type)); } } }(); @@ -714,7 +729,7 @@ ProtoParser::ParseJsonContainsExpr( // auto& field_meta = schema[field_offset]; auto result = [&]() -> ExprPtr { if (expr_pb.elements_size() == 0) { - PanicInfo("no elements in expression"); + PanicInfo(DataIsEmpty, "no elements in expression"); } if (expr_pb.elements_same_type()) { switch (expr_pb.elements(0).val_case()) { @@ -730,7 +745,9 @@ ProtoParser::ParseJsonContainsExpr( return ExtractJsonContainsExprImpl( expr_pb); default: - PanicInfo("unsupported data type"); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported data type {}", data_type)); } } return ExtractJsonContainsExprImpl(expr_pb); @@ -776,7 +793,8 @@ ProtoParser::ParseExpr(const proto::plan::Expr& expr_pb) { default: { std::string s; google::protobuf::TextFormat::PrintToString(expr_pb, &s); - PanicInfo(std::string("unsupported expr proto node: ") + s); + PanicInfo(ExprInvalid, + fmt::format("unsupported expr proto node: {}", s)); } } } diff --git a/internal/core/src/query/PlanProto.h b/internal/core/src/query/PlanProto.h index b6797488b6bbe..806ff62d604fa 100644 --- a/internal/core/src/query/PlanProto.h +++ b/internal/core/src/query/PlanProto.h @@ -98,6 +98,9 @@ struct fmt::formatter case milvus::proto::plan::GenericValue::ValCase::kStringVal: name = "kStringVal"; break; + case milvus::proto::plan::GenericValue::ValCase::kArrayVal: + name = "kArrayVal"; + break; case milvus::proto::plan::GenericValue::ValCase::VAL_NOT_SET: name = "VAL_NOT_SET"; break; diff --git a/internal/core/src/query/Relational.h b/internal/core/src/query/Relational.h index b520226d57df3..1839221db65ce 100644 --- a/internal/core/src/query/Relational.h +++ b/internal/core/src/query/Relational.h @@ -30,13 +30,13 @@ RelationalImpl(const T& t, const U& u, FundamentalTag, FundamentalTag) { template bool RelationalImpl(const T& t, const U& u, FundamentalTag, StringTag) { - PanicInfo("incompitible data type"); + PanicInfo(DataTypeInvalid, "incompitible data type"); } template bool RelationalImpl(const T& t, const U& u, StringTag, FundamentalTag) { - PanicInfo("incompitible data type"); + PanicInfo(DataTypeInvalid, "incompitible data type"); } template @@ -59,7 +59,7 @@ struct Relational { template bool operator()(const T&...) const { - PanicInfo("incompatible operands"); + PanicInfo(OpTypeInvalid, "incompatible operands"); } }; diff --git a/internal/core/src/query/ScalarIndex.h b/internal/core/src/query/ScalarIndex.h index 33794da454eed..b3ea232cc165a 100644 --- a/internal/core/src/query/ScalarIndex.h +++ b/internal/core/src/query/ScalarIndex.h @@ -58,7 +58,8 @@ generate_scalar_index(SpanBase data, DataType data_type) { case DataType::VARCHAR: return generate_scalar_index(Span(data)); default: - PanicInfo("unsupported type"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported type {}", data_type)); } } diff --git a/internal/core/src/query/SearchBruteForce.cpp b/internal/core/src/query/SearchBruteForce.cpp index fb49caf43fec5..4e6ea4bd64087 100644 --- a/internal/core/src/query/SearchBruteForce.cpp +++ b/internal/core/src/query/SearchBruteForce.cpp @@ -105,10 +105,10 @@ BruteForceSearch(const dataset::SearchDataset& dataset, base_dataset, query_dataset, config, bitset); milvus::tracer::AddEvent("knowhere_finish_BruteForce_RangeSearch"); if (!res.has_value()) { - PanicCodeInfo(KnowhereError, - fmt::format("failed to range search: {}: {}", - KnowhereStatusString(res.error()), - res.what())); + PanicInfo(KnowhereError, + fmt::format("failed to range search: {}: {}", + KnowhereStatusString(res.error()), + res.what())); } auto result = ReGenRangeSearchResult(res.value(), topk, nq, dataset.metric_type); diff --git a/internal/core/src/query/Utils.h b/internal/core/src/query/Utils.h index 30a5d2bad4eb8..8e7ba5170cd04 100644 --- a/internal/core/src/query/Utils.h +++ b/internal/core/src/query/Utils.h @@ -22,7 +22,7 @@ namespace milvus::query { template inline bool Match(const T& x, const U& y, OpType op) { - PanicInfo("not supported"); + PanicInfo(NotImplemented, "not supported"); } template <> @@ -34,7 +34,7 @@ Match(const std::string& str, const std::string& val, OpType op) { case OpType::PostfixMatch: return PostfixMatch(str, val); default: - PanicInfo("not supported"); + PanicInfo(OpTypeInvalid, "not supported"); } } @@ -49,7 +49,7 @@ Match(const std::string_view& str, case OpType::PostfixMatch: return PostfixMatch(str, val); default: - PanicInfo("not supported"); + PanicInfo(OpTypeInvalid, "not supported"); } } diff --git a/internal/core/src/query/visitors/ExecExprVisitor.cpp b/internal/core/src/query/visitors/ExecExprVisitor.cpp index 7c9f6b0beb826..06bf573f05a7d 100644 --- a/internal/core/src/query/visitors/ExecExprVisitor.cpp +++ b/internal/core/src/query/visitors/ExecExprVisitor.cpp @@ -28,6 +28,7 @@ #include "common/Json.h" #include "common/Types.h" #include "common/EasyAssert.h" +#include "fmt/core.h" #include "pb/plan.pb.h" #include "query/ExprImpl.h" #include "query/Relational.h" @@ -117,7 +118,8 @@ ExecExprVisitor::visit(LogicalUnaryExpr& expr) { break; } default: { - PanicInfo("Invalid Unary Op"); + PanicInfo(OpTypeInvalid, + fmt::format("Invalid Unary Op {}", expr.op_type_)); } } AssertInfo(res.size() == row_count_, @@ -164,7 +166,8 @@ ExecExprVisitor::visit(LogicalBinaryExpr& expr) { break; } default: { - PanicInfo("Invalid Binary Op"); + PanicInfo(OpTypeInvalid, + fmt::format("Invalid Binary Op {}", expr.op_type_)); } } AssertInfo(res.size() == row_count_, @@ -440,7 +443,8 @@ ExecExprVisitor::ExecUnaryRangeVisitorDispatcherImpl(UnaryRangeExpr& expr_raw) } // TODO: PostfixMatch default: { - PanicInfo("unsupported range node"); + PanicInfo(OpTypeInvalid, + fmt::format("unsupported range node {}", op)); } } } @@ -494,7 +498,9 @@ ExecExprVisitor::ExecUnaryRangeVisitorDispatcher(UnaryRangeExpr& expr_raw) } default: { - PanicInfo("unsupported range node"); + PanicInfo( + OpTypeInvalid, + fmt::format("unsupported range node {}", expr.op_type_)); } } } @@ -550,9 +556,9 @@ CompareTwoJsonArray(T arr1, const proto::plan::Array& arr2) { break; } default: - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported data type {}", - arr2.array(i).val_case())); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", + arr2.array(i).val_case())); } i++; } @@ -693,7 +699,8 @@ ExecExprVisitor::ExecUnaryRangeVisitorDispatcherJson(UnaryRangeExpr& expr_raw) } // TODO: PostfixMatch default: { - PanicInfo("unsupported range node"); + PanicInfo(OpTypeInvalid, + fmt::format("unsupported range node {}", op)); } } } @@ -805,7 +812,8 @@ ExecExprVisitor::ExecUnaryRangeVisitorDispatcherArray(UnaryRangeExpr& expr_raw) } // TODO: PostfixMatch default: { - PanicInfo("unsupported range node"); + PanicInfo(OpTypeInvalid, + fmt::format("unsupported range node {}", op)); } } } @@ -896,7 +904,9 @@ ExecExprVisitor::ExecBinaryArithOpEvalRangeVisitorDispatcher( expr.column_.field_id, index_func, elem_func); } default: { - PanicInfo("unsupported arithmetic operation"); + PanicInfo( + OpTypeInvalid, + fmt::format("unsupported arithmetic operation {}", op)); } } } @@ -963,12 +973,17 @@ ExecExprVisitor::ExecBinaryArithOpEvalRangeVisitorDispatcher( expr.column_.field_id, index_func, elem_func); } default: { - PanicInfo("unsupported arithmetic operation"); + PanicInfo( + OpTypeInvalid, + fmt::format("unsupported arithmetic operation {}", op)); } } } default: { - PanicInfo("unsupported range node with arithmetic operation"); + PanicInfo( + OpTypeInvalid, + fmt::format( + "unsupported range node with arithmetic operation {}", op)); } } } @@ -1100,7 +1115,9 @@ ExecExprVisitor::ExecBinaryArithOpEvalRangeVisitorDispatcherJson( expr.column_.field_id, index_func, elem_func); } default: { - PanicInfo("unsupported arithmetic operation"); + PanicInfo( + OpTypeInvalid, + fmt::format("unsupported arithmetic operation {}", op)); } } } @@ -1185,12 +1202,17 @@ ExecExprVisitor::ExecBinaryArithOpEvalRangeVisitorDispatcherJson( expr.column_.field_id, index_func, elem_func); } default: { - PanicInfo("unsupported arithmetic operation"); + PanicInfo( + OpTypeInvalid, + fmt::format("unsupported arithmetic operation {}", op)); } } } default: { - PanicInfo("unsupported range node with arithmetic operation"); + PanicInfo( + OpTypeInvalid, + fmt::format( + "unsupported range node with arithmetic operation {}", op)); } } } // namespace milvus::query @@ -1292,7 +1314,9 @@ ExecExprVisitor::ExecBinaryArithOpEvalRangeVisitorDispatcherArray( expr.column_.field_id, index_func, elem_func); } default: { - PanicInfo("unsupported arithmetic operation"); + PanicInfo( + OpTypeInvalid, + fmt::format("unsupported arithmetic operation {}", op)); } } } @@ -1371,12 +1395,17 @@ ExecExprVisitor::ExecBinaryArithOpEvalRangeVisitorDispatcherArray( expr.column_.field_id, index_func, elem_func); } default: { - PanicInfo("unsupported arithmetic operation"); + PanicInfo( + OpTypeInvalid, + fmt::format("unsupported arithmetic operation {}", op)); } } } default: { - PanicInfo("unsupported range node with arithmetic operation"); + PanicInfo( + OpTypeInvalid, + fmt::format( + "unsupported range node with arithmetic operation {}", op)); } } } // namespace milvus::query @@ -1640,6 +1669,7 @@ ExecExprVisitor::visit(UnaryRangeExpr& expr) { break; default: PanicInfo( + DataTypeInvalid, fmt::format("unknown data type: {}", expr.val_case_)); } break; @@ -1665,12 +1695,14 @@ ExecExprVisitor::visit(UnaryRangeExpr& expr) { break; default: PanicInfo( + DataTypeInvalid, fmt::format("unknown data type: {}", expr.val_case_)); } break; } default: - PanicInfo(fmt::format("unsupported data type: {}", + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type: {}", expr.column_.data_type)); } AssertInfo(res.size() == row_count_, @@ -1729,6 +1761,7 @@ ExecExprVisitor::visit(BinaryArithOpEvalRangeExpr& expr) { } default: { PanicInfo( + DataTypeInvalid, fmt::format("unsupported value type {} in expression", expr.val_case_)); } @@ -1749,6 +1782,7 @@ ExecExprVisitor::visit(BinaryArithOpEvalRangeExpr& expr) { } default: { PanicInfo( + DataTypeInvalid, fmt::format("unsupported value type {} in expression", expr.val_case_)); } @@ -1756,7 +1790,8 @@ ExecExprVisitor::visit(BinaryArithOpEvalRangeExpr& expr) { break; } default: - PanicInfo(fmt::format("unsupported data type: {}", + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type: {}", expr.column_.data_type)); } AssertInfo(res.size() == row_count_, @@ -1824,6 +1859,7 @@ ExecExprVisitor::visit(BinaryRangeExpr& expr) { } default: { PanicInfo( + DataTypeInvalid, fmt::format("unsupported value type {} in expression", expr.val_case_)); } @@ -1846,8 +1882,8 @@ ExecExprVisitor::visit(BinaryRangeExpr& expr) { break; } default: { - PanicCodeInfo( - Unsupported, + PanicInfo( + DataTypeInvalid, fmt::format("unsupported value type {} in expression", expr.val_case_)); } @@ -1855,7 +1891,8 @@ ExecExprVisitor::visit(BinaryRangeExpr& expr) { break; } default: - PanicInfo(fmt::format("unsupported data type: {}", + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type: {}", expr.column_.data_type)); } AssertInfo(res.size() == row_count_, @@ -1873,7 +1910,7 @@ struct relational { template bool operator()(T const&...) const { - PanicInfo("incompatible operands"); + PanicInfo(OpTypeInvalid, "incompatible operands"); } }; @@ -1946,7 +1983,10 @@ ExecExprVisitor::ExecCompareLeftType(const FieldId& left_field_id, left_raw_data, right_field_id, chunk_id, cmp_func); break; default: - PanicInfo("unsupported left datatype of compare expr"); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported right datatype {} of compare expr", + right_field_type)); } results.push_back(result); } @@ -1997,7 +2037,10 @@ ExecExprVisitor::ExecCompareExprDispatcherForNonIndexedSegment( expr.right_data_type_, cmp_func); default: - PanicInfo("unsupported right datatype of compare expr"); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported right datatype {} of compare expr", + expr.left_data_type_)); } } @@ -2202,9 +2245,8 @@ ExecExprVisitor::ExecCompareExprDispatcher(CompareExpr& expr, Op op) } } default: - PanicCodeInfo( - DataTypeInvalid, - fmt::format("unsupported data type {}", type)); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", type)); } }; auto left = getChunkData( @@ -2272,9 +2314,8 @@ ExecExprVisitor::visit(CompareExpr& expr) { // case OpType::PostfixMatch: { // } default: { - PanicCodeInfo(OpTypeInvalid, - fmt::format("unsupported optype {}", - fmt::underlying(expr.op_type_))); + PanicInfo(OpTypeInvalid, + fmt::format("unsupported optype {}", expr.op_type_)); } } AssertInfo(res.size() == row_count_, @@ -2318,7 +2359,7 @@ ExecExprVisitor::ExecTermVisitorImpl(TermExpr& expr_raw) -> BitsetType { break; } default: { - PanicCodeInfo( + PanicInfo( DataTypeInvalid, fmt::format("unsupported data type {}", expr.val_case_)); } @@ -2651,9 +2692,9 @@ ExecExprVisitor::visit(TermExpr& expr) { res = ExecTermVisitorImplTemplateJson(expr); break; default: - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported data type {}", - expr.val_case_)); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", + expr.val_case_)); } break; } @@ -2675,16 +2716,16 @@ ExecExprVisitor::visit(TermExpr& expr) { res = ExecTermVisitorImplTemplateArray(expr); break; default: - PanicCodeInfo( + PanicInfo( Unsupported, fmt::format("unknown data type: {}", expr.val_case_)); } break; } default: - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported data type {}", - expr.column_.data_type)); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", + expr.column_.data_type)); } AssertInfo(res.size() == row_count_, "[ExecExprVisitor]Size of results not equal row count"); @@ -2711,9 +2752,9 @@ ExecExprVisitor::visit(ExistsExpr& expr) { break; } default: - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported data type {}", - expr.column_.data_type)); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", + expr.column_.data_type)); } AssertInfo(res.size() == row_count_, "[ExecExprVisitor]Size of results not equal row count"); @@ -2902,9 +2943,9 @@ ExecExprVisitor::ExecJsonContainsWithDiffType(JsonContainsExpr& expr_raw) break; } default: - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported data type {}", - element.val_case())); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", + element.val_case())); } } } @@ -3052,84 +3093,84 @@ ExecExprVisitor::ExecJsonContainsAllWithDiffType(JsonContainsExpr& expr_raw) elements_index.insert(i); i++; } - auto elem_func = [&elements, &elements_index, &pointer]( - const milvus::Json& json) { - auto doc = json.doc(); - auto array = doc.at_pointer(pointer).get_array(); - if (array.error()) { - return false; - } - std::unordered_set tmp_elements_index(elements_index); - for (auto&& it : array) { - int i = -1; - for (auto& element : elements) { - i++; - switch (element.val_case()) { - case proto::plan::GenericValue::kBoolVal: { - auto val = it.template get(); - if (val.error()) { - continue; - } - if (val.value() == element.bool_val()) { - tmp_elements_index.erase(i); - } - break; - } - case proto::plan::GenericValue::kInt64Val: { - auto val = it.template get(); - if (val.error()) { - continue; - } - if (val.value() == element.int64_val()) { - tmp_elements_index.erase(i); - } - break; - } - case proto::plan::GenericValue::kFloatVal: { - auto val = it.template get(); - if (val.error()) { - continue; - } - if (val.value() == element.float_val()) { - tmp_elements_index.erase(i); + auto elem_func = + [&elements, &elements_index, &pointer](const milvus::Json& json) { + auto doc = json.doc(); + auto array = doc.at_pointer(pointer).get_array(); + if (array.error()) { + return false; + } + std::unordered_set tmp_elements_index(elements_index); + for (auto&& it : array) { + int i = -1; + for (auto& element : elements) { + i++; + switch (element.val_case()) { + case proto::plan::GenericValue::kBoolVal: { + auto val = it.template get(); + if (val.error()) { + continue; + } + if (val.value() == element.bool_val()) { + tmp_elements_index.erase(i); + } + break; } - break; - } - case proto::plan::GenericValue::kStringVal: { - auto val = it.template get(); - if (val.error()) { - continue; + case proto::plan::GenericValue::kInt64Val: { + auto val = it.template get(); + if (val.error()) { + continue; + } + if (val.value() == element.int64_val()) { + tmp_elements_index.erase(i); + } + break; } - if (val.value() == element.string_val()) { - tmp_elements_index.erase(i); + case proto::plan::GenericValue::kFloatVal: { + auto val = it.template get(); + if (val.error()) { + continue; + } + if (val.value() == element.float_val()) { + tmp_elements_index.erase(i); + } + break; } - break; - } - case proto::plan::GenericValue::kArrayVal: { - auto val = it.get_array(); - if (val.error()) { - continue; + case proto::plan::GenericValue::kStringVal: { + auto val = it.template get(); + if (val.error()) { + continue; + } + if (val.value() == element.string_val()) { + tmp_elements_index.erase(i); + } + break; } - if (CompareTwoJsonArray(val, element.array_val())) { - tmp_elements_index.erase(i); + case proto::plan::GenericValue::kArrayVal: { + auto val = it.get_array(); + if (val.error()) { + continue; + } + if (CompareTwoJsonArray(val, element.array_val())) { + tmp_elements_index.erase(i); + } + break; } - break; - } - default: - PanicCodeInfo(DataTypeInvalid, + default: + PanicInfo(DataTypeInvalid, fmt::format("unsupported data type {}", element.val_case())); + } + if (tmp_elements_index.size() == 0) { + return true; + } } if (tmp_elements_index.size() == 0) { return true; } } - if (tmp_elements_index.size() == 0) { - return true; - } - } - return tmp_elements_index.size() == 0; - }; + return tmp_elements_index.size() == 0; + }; return ExecRangeVisitorImpl( expr.column_.field_id, index_func, elem_func); @@ -3166,9 +3207,9 @@ ExecExprVisitor::visit(JsonContainsExpr& expr) { break; } default: - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported data type {}", - expr.val_case_)); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", + expr.val_case_)); } } else { if (expr.same_type_) { @@ -3194,10 +3235,9 @@ ExecExprVisitor::visit(JsonContainsExpr& expr) { break; } default: - PanicCodeInfo( - Unsupported, - fmt::format("unsupported value type {}", - expr.val_case_)); + PanicInfo(Unsupported, + fmt::format("unsupported value type {}", + expr.val_case_)); } } else { res = ExecJsonContainsWithDiffType(expr); @@ -3225,9 +3265,9 @@ ExecExprVisitor::visit(JsonContainsExpr& expr) { break; } default: - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported data type {}", - expr.val_case_)); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", + expr.val_case_)); } } else { if (expr.same_type_) { @@ -3253,7 +3293,7 @@ ExecExprVisitor::visit(JsonContainsExpr& expr) { break; } default: - PanicCodeInfo( + PanicInfo( Unsupported, fmt::format( "unsupported value type {} in expression", @@ -3266,9 +3306,9 @@ ExecExprVisitor::visit(JsonContainsExpr& expr) { break; } default: - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported json contains type {}", - expr.val_case_)); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported json contains type {}", + expr.val_case_)); } AssertInfo(res.size() == row_count_, "[ExecExprVisitor]Size of results not equal row count"); diff --git a/internal/core/src/query/visitors/ShowExprVisitor.cpp b/internal/core/src/query/visitors/ShowExprVisitor.cpp index 7e4081065debb..55c892240889c 100644 --- a/internal/core/src/query/visitors/ShowExprVisitor.cpp +++ b/internal/core/src/query/visitors/ShowExprVisitor.cpp @@ -14,6 +14,7 @@ #include "query/ExprImpl.h" #include "query/Plan.h" #include "query/generated/ShowExprVisitor.h" +#include "common/Types.h" namespace milvus::query { using Json = nlohmann::json; @@ -90,7 +91,8 @@ ShowExprVisitor::visit(LogicalBinaryExpr& expr) { case OpType::LogicalXor: return "LogicalXor"; default: - PanicInfo("unsupported op"); + PanicInfo(OpTypeInvalid, + fmt::format("unsupported operation {}", op)); } }(expr.op_type_); @@ -134,7 +136,9 @@ ShowExprVisitor::visit(TermExpr& expr) { case DataType::JSON: return TermExtract(expr); default: - PanicInfo("unsupported type"); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported type {}", expr.column_.data_type)); } }(); @@ -192,7 +196,9 @@ ShowExprVisitor::visit(UnaryRangeExpr& expr) { json_opt_ = UnaryRangeExtract(expr); return; default: - PanicInfo("unsupported type"); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported type {}", expr.column_.data_type)); } } @@ -247,7 +253,9 @@ ShowExprVisitor::visit(BinaryRangeExpr& expr) { json_opt_ = BinaryRangeExtract(expr); return; default: - PanicInfo("unsupported type"); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported type {}", expr.column_.data_type)); } } @@ -317,7 +325,9 @@ ShowExprVisitor::visit(BinaryArithOpEvalRangeExpr& expr) { json_opt_ = BinaryArithOpEvalRangeExtract(expr); return; default: - PanicInfo("unsupported type"); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported type {}", expr.column_.data_type)); } } diff --git a/internal/core/src/segcore/ConcurrentVector.cpp b/internal/core/src/segcore/ConcurrentVector.cpp index 3add8f1ea8921..972a81dd057b0 100644 --- a/internal/core/src/segcore/ConcurrentVector.cpp +++ b/internal/core/src/segcore/ConcurrentVector.cpp @@ -34,7 +34,7 @@ VectorBase::set_data_raw(ssize_t element_offset, return set_data_raw( element_offset, VEC_FIELD_DATA(data, float16), element_count); } else { - PanicCodeInfo(DataTypeInvalid, "unsupported"); + PanicInfo(DataTypeInvalid, "unsupported"); } } @@ -98,9 +98,9 @@ VectorBase::set_data_raw(ssize_t element_offset, return set_data_raw(element_offset, data_raw.data(), element_count); } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported datatype {}", - field_meta.get_data_type())); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported datatype {}", + field_meta.get_data_type())); } } } diff --git a/internal/core/src/segcore/ConcurrentVector.h b/internal/core/src/segcore/ConcurrentVector.h index 185ecb83127e4..6ccc2a879be2e 100644 --- a/internal/core/src/segcore/ConcurrentVector.h +++ b/internal/core/src/segcore/ConcurrentVector.h @@ -183,7 +183,7 @@ class ConcurrentVectorImpl : public VectorBase { } else if constexpr (std::is_same_v || // NOLINT std::is_same_v) { // only for testing - PanicCodeInfo(NotImplemented, "unimplemented"); + PanicInfo(NotImplemented, "unimplemented"); } else { static_assert( std::is_same_v); diff --git a/internal/core/src/segcore/FieldIndexing.cpp b/internal/core/src/segcore/FieldIndexing.cpp index deafdf3c0727d..f86245f2e57f2 100644 --- a/internal/core/src/segcore/FieldIndexing.cpp +++ b/internal/core/src/segcore/FieldIndexing.cpp @@ -250,10 +250,9 @@ CreateIndex(const FieldMeta& field_meta, segment_max_row_count, segcore_config); } else { - PanicCodeInfo( - DataTypeInvalid, - fmt::format("unsupported vector type in index: {}", - fmt::underlying(field_meta.get_data_type()))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported vector type in index: {}", + field_meta.get_data_type())); } } switch (field_meta.get_data_type()) { @@ -282,10 +281,9 @@ CreateIndex(const FieldMeta& field_meta, return std::make_unique>( field_meta, segcore_config); default: - PanicCodeInfo( - DataTypeInvalid, - fmt::format("unsupported scalar type in index: {}", - fmt::underlying(field_meta.get_data_type()))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported scalar type in index: {}", + field_meta.get_data_type())); } } diff --git a/internal/core/src/segcore/FieldIndexing.h b/internal/core/src/segcore/FieldIndexing.h index fe08bbacd0cd2..ee3038b6a654c 100644 --- a/internal/core/src/segcore/FieldIndexing.h +++ b/internal/core/src/segcore/FieldIndexing.h @@ -111,8 +111,8 @@ class ScalarFieldIndexing : public FieldIndexing { int64_t size, const VectorBase* vec_base, const void* data_source) override { - PanicCodeInfo(Unsupported, - "scalar index don't support append segment index"); + PanicInfo(Unsupported, + "scalar index don't support append segment index"); } void @@ -120,8 +120,8 @@ class ScalarFieldIndexing : public FieldIndexing { int64_t count, int64_t element_size, void* output) override { - PanicCodeInfo(Unsupported, - "scalar index don't support get data from index"); + PanicInfo(Unsupported, + "scalar index don't support get data from index"); } idx_t get_index_cursor() override { diff --git a/internal/core/src/segcore/InsertRecord.h b/internal/core/src/segcore/InsertRecord.h index 729261392582d..b03a09e53e994 100644 --- a/internal/core/src/segcore/InsertRecord.h +++ b/internal/core/src/segcore/InsertRecord.h @@ -87,7 +87,7 @@ class OffsetOrderedMap : public OffsetMap { void seal() override { - PanicCodeInfo( + PanicInfo( NotImplemented, "OffsetOrderedMap used for growing segment could not be sealed."); } @@ -182,8 +182,8 @@ class OffsetOrderedArray : public OffsetMap { void insert(const PkType& pk, int64_t offset) override { if (is_sealed) { - PanicCodeInfo(Unsupported, - "OffsetOrderedArray could not insert after seal"); + PanicInfo(Unsupported, + "OffsetOrderedArray could not insert after seal"); } array_.push_back(std::make_pair(std::get(pk), offset)); } @@ -294,11 +294,9 @@ struct InsertRecord { break; } default: { - PanicCodeInfo( - DataTypeInvalid, - fmt::format( - "unsupported pk type", - fmt::underlying(field_meta.get_data_type()))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported pk type", + field_meta.get_data_type())); } } } @@ -318,10 +316,9 @@ struct InsertRecord { field_id, field_meta.get_dim(), size_per_chunk); continue; } else { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported vector type", - fmt::underlying( - field_meta.get_data_type()))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported vector type", + field_meta.get_data_type())); } } switch (field_meta.get_data_type()) { @@ -367,10 +364,9 @@ struct InsertRecord { break; } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported scalar type", - fmt::underlying( - field_meta.get_data_type()))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported scalar type", + field_meta.get_data_type())); } } } @@ -420,9 +416,9 @@ struct InsertRecord { break; } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported primary key data type", - fmt::underlying(data_type))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported primary key data type", + data_type)); } } } @@ -452,10 +448,9 @@ struct InsertRecord { break; } default: { - PanicCodeInfo( - DataTypeInvalid, - fmt::format("unsupported primary key data type", - fmt::underlying(data_type))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported primary key data type", + data_type)); } } } diff --git a/internal/core/src/segcore/Reduce.cpp b/internal/core/src/segcore/Reduce.cpp index 3ec7f91855f94..46ca71d84dfbf 100644 --- a/internal/core/src/segcore/Reduce.cpp +++ b/internal/core/src/segcore/Reduce.cpp @@ -318,9 +318,8 @@ ReduceHelper::GetSearchResultDataSlice(int slice_index) { break; } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported primary key type {}", - fmt::underlying(pk_type))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported primary key type {}", pk_type)); } } @@ -367,10 +366,9 @@ ReduceHelper::GetSearchResultDataSlice(int slice_index) { break; } default: { - PanicCodeInfo( - DataTypeInvalid, - fmt::format("unsupported primary key type {}", - fmt::underlying(pk_type))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported primary key type {}", + pk_type)); } } diff --git a/internal/core/src/segcore/SegcoreConfig.cpp b/internal/core/src/segcore/SegcoreConfig.cpp index 45cf82726d67c..478100e640a7a 100644 --- a/internal/core/src/segcore/SegcoreConfig.cpp +++ b/internal/core/src/segcore/SegcoreConfig.cpp @@ -37,7 +37,7 @@ apply_parser(const YAML::Node& node, Func func) { results.emplace_back(func(element)); } } else { - PanicCodeInfo(ConfigInvalid, "node should be scalar or sequence"); + PanicInfo(ConfigInvalid, "node should be scalar or sequence"); } return results; } @@ -102,7 +102,7 @@ SegcoreConfig::parse_from(const std::string& config_path) { } catch (const std::exception& e) { std::string str = std::string("Invalid Yaml: ") + config_path + ", err: " + e.what(); - PanicCodeInfo(ConfigInvalid, str); + PanicInfo(ConfigInvalid, str); } } diff --git a/internal/core/src/segcore/SegmentGrowingImpl.cpp b/internal/core/src/segcore/SegmentGrowingImpl.cpp index 637ba44e2b4c2..72a2295febce0 100644 --- a/internal/core/src/segcore/SegmentGrowingImpl.cpp +++ b/internal/core/src/segcore/SegmentGrowingImpl.cpp @@ -364,7 +364,7 @@ SegmentGrowingImpl::bulk_subscript(FieldId field_id, count, output.data()); } else { - PanicCodeInfo(DataTypeInvalid, "logical error"); + PanicInfo(DataTypeInvalid, "logical error"); } return CreateVectorDataArrayFrom(output.data(), count, field_meta); } @@ -433,10 +433,9 @@ SegmentGrowingImpl::bulk_subscript(FieldId field_id, return CreateScalarDataArrayFrom(output.data(), count, field_meta); } default: { - PanicCodeInfo( + PanicInfo( DataTypeInvalid, - fmt::format("unsupported type {}", - fmt::underlying(field_meta.get_data_type()))); + fmt::format("unsupported type {}", field_meta.get_data_type())); } } } @@ -531,7 +530,7 @@ SegmentGrowingImpl::bulk_subscript(SystemFieldType system_type, &this->insert_record_.row_ids_, seg_offsets, count, output); break; default: - PanicCodeInfo(DataTypeInvalid, "unknown subscript fields"); + PanicInfo(DataTypeInvalid, "unknown subscript fields"); } } @@ -564,9 +563,8 @@ SegmentGrowingImpl::search_ids(const IdArray& id_array, break; } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported type {}", - fmt::underlying(data_type))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported type {}", data_type)); } } res_offsets.push_back(offset); diff --git a/internal/core/src/segcore/SegmentInterface.cpp b/internal/core/src/segcore/SegmentInterface.cpp index 475824038dc82..bbc08206059e5 100644 --- a/internal/core/src/segcore/SegmentInterface.cpp +++ b/internal/core/src/segcore/SegmentInterface.cpp @@ -165,9 +165,9 @@ SegmentInternalInterface::Retrieve(const query::RetrievePlan* plan, break; } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported datatype {}", - field_meta.get_data_type())); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported datatype {}", + field_meta.get_data_type())); } } } diff --git a/internal/core/src/segcore/SegmentSealedImpl.cpp b/internal/core/src/segcore/SegmentSealedImpl.cpp index b4d53d9467056..608cdc6fce94f 100644 --- a/internal/core/src/segcore/SegmentSealedImpl.cpp +++ b/internal/core/src/segcore/SegmentSealedImpl.cpp @@ -160,9 +160,9 @@ SegmentSealedImpl::LoadScalarIndex(const LoadIndexInfo& info) { break; } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported primary key type", - field_meta.get_data_type())); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported primary key type {}", + field_meta.get_data_type())); } } } @@ -330,7 +330,8 @@ SegmentSealedImpl::LoadFieldData(FieldId field_id, FieldDataInfo& data) { break; } default: { - PanicInfo("unsupported data type"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type", data_type)); } } @@ -443,7 +444,8 @@ SegmentSealedImpl::MapFieldData(const FieldId field_id, FieldDataInfo& data) { break; } default: { - PanicInfo(fmt::format("unsupported data type {}", data_type)); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", data_type)); } } } else { @@ -782,9 +784,10 @@ SegmentSealedImpl::check_search(const query::Plan* plan) const { if (!is_system_field_ready()) { PanicInfo( + FieldNotLoaded, "failed to load row ID or timestamp, potential missing bin logs or " "empty segments. Segment ID = " + - std::to_string(this->id_)); + std::to_string(this->id_)); } auto& request_fields = plan->extra_info_opt_.value().involved_fields_; @@ -798,17 +801,18 @@ SegmentSealedImpl::check_search(const query::Plan* plan) const { auto field_id = FieldId(absent_fields.find_first() + START_USER_FIELDID); auto& field_meta = schema_->operator[](field_id); - PanicInfo("User Field(" + field_meta.get_name().get() + - ") is not loaded"); + PanicInfo( + FieldNotLoaded, + "User Field(" + field_meta.get_name().get() + ") is not loaded"); } } SegmentSealedImpl::SegmentSealedImpl(SchemaPtr schema, int64_t segment_id) - : schema_(schema), - insert_record_(*schema, MAX_ROW_COUNT), - field_data_ready_bitset_(schema->size()), + : field_data_ready_bitset_(schema->size()), index_ready_bitset_(schema->size()), scalar_indexings_(schema->size()), + insert_record_(*schema, MAX_ROW_COUNT), + schema_(schema), id_(segment_id) { } @@ -853,7 +857,8 @@ SegmentSealedImpl::bulk_subscript(SystemFieldType system_type, output); break; default: - PanicInfo("unknown subscript fields"); + PanicInfo(DataTypeInvalid, + fmt::format("unknown subscript fields", system_type)); } } @@ -986,6 +991,7 @@ SegmentSealedImpl::bulk_subscript(FieldId field_id, default: PanicInfo( + DataTypeInvalid, fmt::format("unsupported data type: {}", datatype_name(field_meta.get_data_type()))); } @@ -1049,7 +1055,9 @@ SegmentSealedImpl::bulk_subscript(FieldId field_id, } default: { - PanicInfo("unsupported"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", + field_meta.get_data_type())); } } } @@ -1117,7 +1125,8 @@ SegmentSealedImpl::search_ids(const IdArray& id_array, break; } default: { - PanicInfo("unsupported type"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported type {}", data_type)); } } res_offsets.push_back(offset); @@ -1182,7 +1191,7 @@ SegmentSealedImpl::LoadSegmentMeta( slice_lengths.push_back(info.row_count()); } insert_record_.timestamp_index_.set_length_meta(std::move(slice_lengths)); - PanicInfo("unimplemented"); + PanicInfo(NotImplemented, "unimplemented"); } int64_t diff --git a/internal/core/src/segcore/Utils.cpp b/internal/core/src/segcore/Utils.cpp index 7ec8fe7ca6403..7928378b0557d 100644 --- a/internal/core/src/segcore/Utils.cpp +++ b/internal/core/src/segcore/Utils.cpp @@ -26,7 +26,8 @@ namespace milvus::segcore { void ParsePksFromFieldData(std::vector& pks, const DataArray& data) { - switch (static_cast(data.type())) { + auto data_type = static_cast(data.type()); + switch (data_type) { case DataType::INT64: { auto source_data = reinterpret_cast( data.scalars().long_data().data().data()); @@ -39,7 +40,8 @@ ParsePksFromFieldData(std::vector& pks, const DataArray& data) { break; } default: { - PanicInfo("unsupported"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported PK {}", data_type)); } } } @@ -68,7 +70,8 @@ ParsePksFromFieldData(DataType data_type, break; } default: { - PanicInfo("unsupported"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported PK {}", data_type)); } } offset += row_count; @@ -92,7 +95,8 @@ ParsePksFromIDs(std::vector& pks, break; } default: { - PanicInfo("unsupported"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported PK {}", data_type)); } } } @@ -107,7 +111,8 @@ GetSizeOfIdArray(const IdArray& data) { return data.str_id().data_size(); } - PanicInfo("unsupported id type"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported id {}", data.descriptor()->name())); } int64_t @@ -188,13 +193,17 @@ GetRawDataSizeOfDataArray(const DataArray* data, break; } default: - PanicInfo("unsupported element type for array"); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported element type for array", + field_meta.get_element_type())); } break; } default: { PanicInfo( + DataTypeInvalid, fmt::format("unsupported variable datatype {}", data_type)); } } @@ -276,7 +285,8 @@ CreateScalarDataArray(int64_t count, const FieldMeta& field_meta) { break; } default: { - PanicInfo("unsupported datatype"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported datatype {}", data_type)); } } @@ -316,7 +326,8 @@ CreateVectorDataArray(int64_t count, const FieldMeta& field_meta) { break; } default: { - PanicInfo("unsupported datatype"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported datatype {}", data_type)); } } return data_array; @@ -401,7 +412,8 @@ CreateScalarDataArrayFrom(const void* data_raw, break; } default: { - PanicInfo("unsupported datatype"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported datatype {}", data_type)); } } @@ -446,7 +458,8 @@ CreateVectorDataArrayFrom(const void* data_raw, break; } default: { - PanicInfo("unsupported datatype"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported datatype {}", data_type)); } } return data_array; @@ -500,7 +513,8 @@ MergeDataArray( auto obj = vector_array->mutable_binary_vector(); obj->assign(data + src_offset * num_bytes, num_bytes); } else { - PanicInfo("logical error"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported datatype {}", data_type)); } continue; } @@ -560,7 +574,8 @@ MergeDataArray( break; } default: { - PanicInfo(fmt::format("unsupported data type {}", data_type)); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported datatype {}", data_type)); } } } @@ -671,7 +686,8 @@ ReverseDataFromIndex(const index::IndexBase* index, break; } default: { - PanicInfo("unsupported datatype"); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported datatype {}", data_type)); } } diff --git a/internal/core/src/segcore/pkVisitor.h b/internal/core/src/segcore/pkVisitor.h index 740e4327970ac..d7fef1fb081f6 100644 --- a/internal/core/src/segcore/pkVisitor.h +++ b/internal/core/src/segcore/pkVisitor.h @@ -19,7 +19,7 @@ struct Int64PKVisitor { template int64_t operator()(T t) const { - PanicCodeInfo(Unsupported, "invalid int64 pk value"); + PanicInfo(Unsupported, "invalid int64 pk value"); } }; @@ -33,7 +33,7 @@ struct StrPKVisitor { template std::string operator()(T t) const { - PanicCodeInfo(Unsupported, "invalid string pk value"); + PanicInfo(Unsupported, "invalid string pk value"); } }; diff --git a/internal/core/src/storage/DataCodec.cpp b/internal/core/src/storage/DataCodec.cpp index d78303f5d099e..2e37f7bf732bc 100644 --- a/internal/core/src/storage/DataCodec.cpp +++ b/internal/core/src/storage/DataCodec.cpp @@ -86,16 +86,16 @@ DeserializeRemoteFileData(BinlogReaderPtr reader) { return index_data; } default: - PanicCodeInfo(DataFormatBroken, - fmt::format("unsupported event type {}", - fmt::underlying(header.event_type_))); + PanicInfo( + DataFormatBroken, + fmt::format("unsupported event type {}", header.event_type_)); } } // For now, no file header in file data std::unique_ptr DeserializeLocalFileData(BinlogReaderPtr reader) { - PanicCodeInfo(NotImplemented, "not supported"); + PanicInfo(NotImplemented, "not supported"); } std::unique_ptr @@ -111,9 +111,8 @@ DeserializeFileData(const std::shared_ptr input_data, return DeserializeLocalFileData(binlog_reader); } default: - PanicCodeInfo(DataFormatBroken, - fmt::format("unsupported medium type {}", - fmt::underlying(medium_type))); + PanicInfo(DataFormatBroken, + fmt::format("unsupported medium type {}", medium_type)); } } diff --git a/internal/core/src/storage/Event.cpp b/internal/core/src/storage/Event.cpp index f7ec2938850b1..55ff73ced2765 100644 --- a/internal/core/src/storage/Event.cpp +++ b/internal/core/src/storage/Event.cpp @@ -65,9 +65,8 @@ GetEventFixPartSize(EventType event_type) { return GetFixPartSize(data); } default: - PanicCodeInfo(DataFormatBroken, - fmt::format("unsupported event type {}", - fmt::underlying(event_type))); + PanicInfo(DataFormatBroken, + fmt::format("unsupported event type {}", event_type)); } } diff --git a/internal/core/src/storage/IndexData.cpp b/internal/core/src/storage/IndexData.cpp index 9010aecfcac3b..6309fd44f7dee 100644 --- a/internal/core/src/storage/IndexData.cpp +++ b/internal/core/src/storage/IndexData.cpp @@ -41,9 +41,8 @@ IndexData::Serialize(StorageType medium) { case StorageType::LocalDisk: return serialize_to_local_file(); default: - PanicCodeInfo(DataFormatBroken, - fmt::format("unsupported medium type {}", - fmt::underlying(medium))); + PanicInfo(DataFormatBroken, + fmt::format("unsupported medium type {}", medium)); } } diff --git a/internal/core/src/storage/InsertData.cpp b/internal/core/src/storage/InsertData.cpp index eaf212ca75b22..514d98d56aac6 100644 --- a/internal/core/src/storage/InsertData.cpp +++ b/internal/core/src/storage/InsertData.cpp @@ -37,9 +37,8 @@ InsertData::Serialize(StorageType medium) { case StorageType::LocalDisk: return serialize_to_local_file(); default: - PanicCodeInfo(DataFormatBroken, - fmt::format("unsupported medium type {}", - fmt::underlying(medium))); + PanicInfo(DataFormatBroken, + fmt::format("unsupported medium type {}", medium)); } } diff --git a/internal/core/src/storage/Types.h b/internal/core/src/storage/Types.h index 0f0ac1aefe6a0..f63b9cbc2968e 100644 --- a/internal/core/src/storage/Types.h +++ b/internal/core/src/storage/Types.h @@ -98,3 +98,59 @@ struct StorageConfig { }; } // namespace milvus::storage + +template <> +struct fmt::formatter : formatter { + auto + format(milvus::storage::EventType c, format_context& ctx) const { + string_view name = "unknown"; + switch (c) { + case milvus::storage::EventType::DescriptorEvent: + name = "DescriptorEvent"; + break; + case milvus::storage::EventType::InsertEvent: + name = "InsertEvent"; + break; + case milvus::storage::EventType::DeleteEvent: + name = "DeleteEvent"; + break; + case milvus::storage::EventType::CreateCollectionEvent: + name = "CreateCollectionEvent"; + break; + case milvus::storage::EventType::DropCollectionEvent: + name = "DropCollectionEvent"; + break; + case milvus::storage::EventType::CreatePartitionEvent: + name = "CreatePartitionEvent"; + break; + case milvus::storage::EventType::DropPartitionEvent: + name = "DropPartitionEvent"; + break; + case milvus::storage::EventType::IndexFileEvent: + name = "IndexFileEvent"; + break; + case milvus::storage::EventType::EventTypeEnd: + name = "EventTypeEnd"; + break; + } + return formatter::format(name, ctx); + } +}; + +template <> +struct fmt::formatter : formatter { + auto + format(milvus::storage::StorageType c, format_context& ctx) const { + switch (c) { + case milvus::storage::StorageType::None: + return formatter::format("None", ctx); + case milvus::storage::StorageType::Memory: + return formatter::format("Memory", ctx); + case milvus::storage::StorageType::LocalDisk: + return formatter::format("LocalDisk", ctx); + case milvus::storage::StorageType::Remote: + return formatter::format("Remote", ctx); + } + return formatter::format("unknown", ctx); + } +}; diff --git a/internal/core/src/storage/Util.cpp b/internal/core/src/storage/Util.cpp index e91a0d6c00de6..8a1a7a3e3a5a0 100644 --- a/internal/core/src/storage/Util.cpp +++ b/internal/core/src/storage/Util.cpp @@ -150,9 +150,8 @@ AddPayloadToArrowBuilder(std::shared_ptr builder, break; } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported data type {}", - fmt::underlying(data_type))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", data_type)); } } } @@ -222,9 +221,9 @@ CreateArrowBuilder(DataType data_type) { return std::make_shared(); } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported numeric data type {}", - fmt::underlying(data_type))); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported numeric data type {}", data_type)); } } } @@ -248,9 +247,9 @@ CreateArrowBuilder(DataType data_type, int dim) { arrow::fixed_size_binary(dim * sizeof(float16))); } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported vector data type {}", - fmt::underlying(data_type))); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported vector data type {}", data_type)); } } } @@ -288,9 +287,9 @@ CreateArrowSchema(DataType data_type) { return arrow::schema({arrow::field("val", arrow::binary())}); } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported numeric data type {}", - fmt::underlying(data_type))); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported numeric data type {}", data_type)); } } } @@ -314,9 +313,9 @@ CreateArrowSchema(DataType data_type, int dim) { "val", arrow::fixed_size_binary(dim * sizeof(float16)))}); } default: { - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported vector data type {}", - fmt::underlying(data_type))); + PanicInfo( + DataTypeInvalid, + fmt::format("unsupported vector data type {}", data_type)); } } } @@ -335,9 +334,8 @@ GetDimensionFromFileMetaData(const parquet::ColumnDescriptor* schema, return schema->type_length() / sizeof(float16); } default: - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported data type {}", - fmt::underlying(data_type))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", data_type)); } } @@ -362,9 +360,8 @@ GetDimensionFromArrowArray(std::shared_ptr data, return array->byte_width() * 8; } default: - PanicCodeInfo(DataTypeInvalid, - fmt::format("unsupported data type {}", - fmt::underlying(data_type))); + PanicInfo(DataTypeInvalid, + fmt::format("unsupported data type {}", data_type)); } } @@ -606,10 +603,9 @@ CreateChunkManager(const StorageConfig& storage_config) { } default: { - PanicCodeInfo( - ConfigInvalid, - fmt::format("unsupported storage_config.storage_type {}", - fmt::underlying(storage_type))); + PanicInfo(ConfigInvalid, + fmt::format("unsupported storage_config.storage_type {}", + fmt::underlying(storage_type))); } } } diff --git a/internal/core/unittest/test_bf.cpp b/internal/core/unittest/test_bf.cpp index 78bdede9677a0..f0e64b087b4c3 100644 --- a/internal/core/unittest/test_bf.cpp +++ b/internal/core/unittest/test_bf.cpp @@ -56,7 +56,7 @@ Distances(const float* base, } return res; } else { - PanicCodeInfo(MetricTypeInvalid, "invalid metric type"); + PanicInfo(MetricTypeInvalid, "invalid metric type"); } } @@ -85,7 +85,7 @@ Ref(const float* base, } else if (milvus::IsMetricType(metric, knowhere::metric::IP)) { std::reverse(res.begin(), res.end()); } else { - PanicCodeInfo(MetricTypeInvalid, "invalid metric type"); + PanicInfo(MetricTypeInvalid, "invalid metric type"); } return GetOffsets(res, topk); } diff --git a/internal/core/unittest/test_c_api.cpp b/internal/core/unittest/test_c_api.cpp index aefb97d454867..26df258bbdfe7 100644 --- a/internal/core/unittest/test_c_api.cpp +++ b/internal/core/unittest/test_c_api.cpp @@ -3982,7 +3982,7 @@ TEST(CApiTest, RetriveScalarFieldFromSealedSegmentWithIndex) { break; } default: { - PanicCodeInfo(DataTypeInvalid, "not supported type"); + PanicInfo(DataTypeInvalid, "not supported type"); } } } diff --git a/internal/core/unittest/test_expr.cpp b/internal/core/unittest/test_expr.cpp index cf3aa29f11bb3..eacc3970e6590 100644 --- a/internal/core/unittest/test_expr.cpp +++ b/internal/core/unittest/test_expr.cpp @@ -762,7 +762,7 @@ TEST(Expr, TestUnaryRangeJson) { break; } default: { - PanicCodeInfo(Unsupported, "unsupported range node"); + PanicInfo(Unsupported, "unsupported range node"); } } @@ -816,9 +816,7 @@ TEST(Expr, TestUnaryRangeJson) { int_val3.set_int64_val(int64_t(3)); arr.add_array()->CopyFrom(int_val3); - std::vector array_cases = { - {arr, {"array"}} - }; + std::vector array_cases = {{arr, {"array"}}}; for (const auto& testcase : array_cases) { auto check = [&](OpType op) { @@ -830,11 +828,12 @@ TEST(Expr, TestUnaryRangeJson) { for (auto& op : ops) { RetrievePlanNode plan; auto pointer = milvus::Json::pointer(testcase.nested_path); - plan.predicate_ = std::make_unique>( - ColumnInfo(json_fid, DataType::JSON, testcase.nested_path), - op, - testcase.val, - proto::plan::GenericValue::ValCase::kArrayVal); + plan.predicate_ = + std::make_unique>( + ColumnInfo(json_fid, DataType::JSON, testcase.nested_path), + op, + testcase.val, + proto::plan::GenericValue::ValCase::kArrayVal); auto final = visitor.call_child(*plan.predicate_.value()); EXPECT_EQ(final.size(), N * num_iters); @@ -4111,9 +4110,7 @@ TEST(Expr, TestJsonContainsArray) { {{sub_arr1, sub_arr2}, {"array2"}}}; for (auto& testcase : diff_testcases2) { - auto check = [&]() { - return true; - }; + auto check = [&]() { return true; }; RetrievePlanNode plan; auto pointer = milvus::Json::pointer(testcase.nested_path); plan.predicate_ = @@ -4248,11 +4245,11 @@ TEST(Expr, TestJsonContainsArray) { } } -milvus::proto::plan::GenericValue generatedArrayWithFourDiffType( - int64_t int_val, - double float_val, - bool bool_val, - std::string string_val) { +milvus::proto::plan::GenericValue +generatedArrayWithFourDiffType(int64_t int_val, + double float_val, + bool bool_val, + std::string string_val) { using namespace milvus; proto::plan::GenericValue value; @@ -4312,11 +4309,15 @@ TEST(Expr, TestJsonContainsDiffTypeArray) { proto::plan::GenericValue int_value; int_value.set_int64_val(1); - auto diff_type_array1 = generatedArrayWithFourDiffType(1, 2.2, false, "abc"); - auto diff_type_array2 = generatedArrayWithFourDiffType(1, 2.2, false, "def"); + auto diff_type_array1 = + generatedArrayWithFourDiffType(1, 2.2, false, "abc"); + auto diff_type_array2 = + generatedArrayWithFourDiffType(1, 2.2, false, "def"); auto diff_type_array3 = generatedArrayWithFourDiffType(1, 2.2, true, "abc"); - auto diff_type_array4 = generatedArrayWithFourDiffType(1, 3.3, false, "abc"); - auto diff_type_array5 = generatedArrayWithFourDiffType(2, 2.2, false, "abc"); + auto diff_type_array4 = + generatedArrayWithFourDiffType(1, 3.3, false, "abc"); + auto diff_type_array5 = + generatedArrayWithFourDiffType(2, 2.2, false, "abc"); std::vector> diff_testcases{ {{diff_type_array1, int_value}, {"array3"}, true}, @@ -4327,9 +4328,7 @@ TEST(Expr, TestJsonContainsDiffTypeArray) { }; for (auto& testcase : diff_testcases) { - auto check = [&]() { - return testcase.res; - }; + auto check = [&]() { return testcase.res; }; RetrievePlanNode plan; auto pointer = milvus::Json::pointer(testcase.nested_path); plan.predicate_ = @@ -4355,9 +4354,7 @@ TEST(Expr, TestJsonContainsDiffTypeArray) { } for (auto& testcase : diff_testcases) { - auto check = [&]() { - return false; - }; + auto check = [&]() { return false; }; RetrievePlanNode plan; auto pointer = milvus::Json::pointer(testcase.nested_path); plan.predicate_ = @@ -4433,10 +4430,13 @@ TEST(Expr, TestJsonContainsDiffType) { proto::plan::GenericValue int_val2; int_val2.set_int64_val(int64_t(1)); - std::vector> diff_testcases{ - {{int_val, bool_val, float_val, string_val}, {"diff_type_array"}, false}, - {{string_val2, bool_val2, float_val2, int_val2}, {"diff_type_array"}, true}, + {{int_val, bool_val, float_val, string_val}, + {"diff_type_array"}, + false}, + {{string_val2, bool_val2, float_val2, int_val2}, + {"diff_type_array"}, + true}, }; for (auto& testcase : diff_testcases) { diff --git a/internal/core/unittest/test_utils/DataGen.h b/internal/core/unittest/test_utils/DataGen.h index 90139146794ed..ca3c652843de6 100644 --- a/internal/core/unittest/test_utils/DataGen.h +++ b/internal/core/unittest/test_utils/DataGen.h @@ -115,7 +115,7 @@ struct GeneratedData { target_field_data.vectors().float16_vector().data()); std::copy_n(src_data, len, ret.data()); } else { - PanicCodeInfo(Unsupported, "unsupported"); + PanicInfo(Unsupported, "unsupported"); } return std::move(ret); @@ -190,7 +190,7 @@ struct GeneratedData { break; } default: { - PanicCodeInfo(Unsupported, "unsupported"); + PanicInfo(Unsupported, "unsupported"); } } } @@ -206,7 +206,7 @@ struct GeneratedData { } } - PanicCodeInfo(FieldIDInvalid, "field id not find"); + PanicInfo(FieldIDInvalid, "field id not find"); } private: @@ -757,7 +757,7 @@ CreateFieldDataFromDataArray(ssize_t raw_count, break; } default: { - PanicCodeInfo(Unsupported, "unsupported"); + PanicInfo(Unsupported, "unsupported"); } } } else { @@ -828,7 +828,7 @@ CreateFieldDataFromDataArray(ssize_t raw_count, break; } default: { - PanicCodeInfo(Unsupported, "unsupported"); + PanicInfo(Unsupported, "unsupported"); } } } diff --git a/internal/proto/planpb/plan.pb.go b/internal/proto/planpb/plan.pb.go index 06de0040e91da..2edfb4c92706d 100644 --- a/internal/proto/planpb/plan.pb.go +++ b/internal/proto/planpb/plan.pb.go @@ -237,6 +237,7 @@ func (BinaryExpr_BinaryOp) EnumDescriptor() ([]byte, []int) { type GenericValue struct { // Types that are valid to be assigned to Val: + // // *GenericValue_BoolVal // *GenericValue_Int64Val // *GenericValue_FloatVal @@ -1297,6 +1298,7 @@ var xxx_messageInfo_AlwaysTrueExpr proto.InternalMessageInfo type Expr struct { // Types that are valid to be assigned to Expr: + // // *Expr_TermExpr // *Expr_UnaryExpr // *Expr_BinaryExpr @@ -1668,6 +1670,7 @@ func (m *QueryPlanNode) GetLimit() int64 { type PlanNode struct { // Types that are valid to be assigned to Node: + // // *PlanNode_VectorAnns // *PlanNode_Predicates // *PlanNode_Query diff --git a/internal/proto/proxypb/proxy.pb.go b/internal/proto/proxypb/proxy.pb.go index 60ba4e6a11df1..c5cf24fd78b7e 100644 --- a/internal/proto/proxypb/proxy.pb.go +++ b/internal/proto/proxypb/proxy.pb.go @@ -29,8 +29,9 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type InvalidateCollMetaCacheRequest struct { // MsgType: - // DropCollection -> {meta cache, dml channels} - // Other -> {meta cache} + // + // DropCollection -> {meta cache, dml channels} + // Other -> {meta cache} Base *commonpb.MsgBase `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"` DbName string `protobuf:"bytes,2,opt,name=db_name,json=dbName,proto3" json:"db_name,omitempty"` CollectionName string `protobuf:"bytes,3,opt,name=collection_name,json=collectionName,proto3" json:"collection_name,omitempty"` diff --git a/internal/proto/rootcoordpb/root_coord.pb.go b/internal/proto/rootcoordpb/root_coord.pb.go index 7d16956e9bd7f..ff74594ed2d2e 100644 --- a/internal/proto/rootcoordpb/root_coord.pb.go +++ b/internal/proto/rootcoordpb/root_coord.pb.go @@ -793,28 +793,28 @@ type RootCoordClient interface { GetComponentStates(ctx context.Context, in *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error) GetTimeTickChannel(ctx context.Context, in *internalpb.GetTimeTickChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) GetStatisticsChannel(ctx context.Context, in *internalpb.GetStatisticsChannelRequest, opts ...grpc.CallOption) (*milvuspb.StringResponse, error) - //* + // * // @brief This method is used to create collection // // @param CreateCollectionRequest, use to provide collection information to be created. // // @return Status CreateCollection(ctx context.Context, in *milvuspb.CreateCollectionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) - //* + // * // @brief This method is used to delete collection. // // @param DropCollectionRequest, collection name is going to be deleted. // // @return Status DropCollection(ctx context.Context, in *milvuspb.DropCollectionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) - //* + // * // @brief This method is used to test collection existence. // // @param HasCollectionRequest, collection name is going to be tested. // // @return BoolResponse HasCollection(ctx context.Context, in *milvuspb.HasCollectionRequest, opts ...grpc.CallOption) (*milvuspb.BoolResponse, error) - //* + // * // @brief This method is used to get collection schema. // // @param DescribeCollectionRequest, target collection name. @@ -825,28 +825,28 @@ type RootCoordClient interface { CreateAlias(ctx context.Context, in *milvuspb.CreateAliasRequest, opts ...grpc.CallOption) (*commonpb.Status, error) DropAlias(ctx context.Context, in *milvuspb.DropAliasRequest, opts ...grpc.CallOption) (*commonpb.Status, error) AlterAlias(ctx context.Context, in *milvuspb.AlterAliasRequest, opts ...grpc.CallOption) (*commonpb.Status, error) - //* + // * // @brief This method is used to list all collections. // // @return StringListResponse, collection name list ShowCollections(ctx context.Context, in *milvuspb.ShowCollectionsRequest, opts ...grpc.CallOption) (*milvuspb.ShowCollectionsResponse, error) AlterCollection(ctx context.Context, in *milvuspb.AlterCollectionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) - //* + // * // @brief This method is used to create partition // // @return Status CreatePartition(ctx context.Context, in *milvuspb.CreatePartitionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) - //* + // * // @brief This method is used to drop partition // // @return Status DropPartition(ctx context.Context, in *milvuspb.DropPartitionRequest, opts ...grpc.CallOption) (*commonpb.Status, error) - //* + // * // @brief This method is used to test partition existence. // // @return BoolResponse HasPartition(ctx context.Context, in *milvuspb.HasPartitionRequest, opts ...grpc.CallOption) (*milvuspb.BoolResponse, error) - //* + // * // @brief This method is used to show partition information // // @param ShowPartitionRequest, target collection name. @@ -854,7 +854,7 @@ type RootCoordClient interface { // @return StringListResponse ShowPartitions(ctx context.Context, in *milvuspb.ShowPartitionsRequest, opts ...grpc.CallOption) (*milvuspb.ShowPartitionsResponse, error) ShowPartitionsInternal(ctx context.Context, in *milvuspb.ShowPartitionsRequest, opts ...grpc.CallOption) (*milvuspb.ShowPartitionsResponse, error) - // rpc DescribeSegment(milvus.DescribeSegmentRequest) returns (milvus.DescribeSegmentResponse) {} + // rpc DescribeSegment(milvus.DescribeSegmentRequest) returns (milvus.DescribeSegmentResponse) {} ShowSegments(ctx context.Context, in *milvuspb.ShowSegmentsRequest, opts ...grpc.CallOption) (*milvuspb.ShowSegmentsResponse, error) AllocTimestamp(ctx context.Context, in *AllocTimestampRequest, opts ...grpc.CallOption) (*AllocTimestampResponse, error) AllocID(ctx context.Context, in *AllocIDRequest, opts ...grpc.CallOption) (*AllocIDResponse, error) @@ -1327,28 +1327,28 @@ type RootCoordServer interface { GetComponentStates(context.Context, *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) GetTimeTickChannel(context.Context, *internalpb.GetTimeTickChannelRequest) (*milvuspb.StringResponse, error) GetStatisticsChannel(context.Context, *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error) - //* + // * // @brief This method is used to create collection // // @param CreateCollectionRequest, use to provide collection information to be created. // // @return Status CreateCollection(context.Context, *milvuspb.CreateCollectionRequest) (*commonpb.Status, error) - //* + // * // @brief This method is used to delete collection. // // @param DropCollectionRequest, collection name is going to be deleted. // // @return Status DropCollection(context.Context, *milvuspb.DropCollectionRequest) (*commonpb.Status, error) - //* + // * // @brief This method is used to test collection existence. // // @param HasCollectionRequest, collection name is going to be tested. // // @return BoolResponse HasCollection(context.Context, *milvuspb.HasCollectionRequest) (*milvuspb.BoolResponse, error) - //* + // * // @brief This method is used to get collection schema. // // @param DescribeCollectionRequest, target collection name. @@ -1359,28 +1359,28 @@ type RootCoordServer interface { CreateAlias(context.Context, *milvuspb.CreateAliasRequest) (*commonpb.Status, error) DropAlias(context.Context, *milvuspb.DropAliasRequest) (*commonpb.Status, error) AlterAlias(context.Context, *milvuspb.AlterAliasRequest) (*commonpb.Status, error) - //* + // * // @brief This method is used to list all collections. // // @return StringListResponse, collection name list ShowCollections(context.Context, *milvuspb.ShowCollectionsRequest) (*milvuspb.ShowCollectionsResponse, error) AlterCollection(context.Context, *milvuspb.AlterCollectionRequest) (*commonpb.Status, error) - //* + // * // @brief This method is used to create partition // // @return Status CreatePartition(context.Context, *milvuspb.CreatePartitionRequest) (*commonpb.Status, error) - //* + // * // @brief This method is used to drop partition // // @return Status DropPartition(context.Context, *milvuspb.DropPartitionRequest) (*commonpb.Status, error) - //* + // * // @brief This method is used to test partition existence. // // @return BoolResponse HasPartition(context.Context, *milvuspb.HasPartitionRequest) (*milvuspb.BoolResponse, error) - //* + // * // @brief This method is used to show partition information // // @param ShowPartitionRequest, target collection name. @@ -1388,7 +1388,7 @@ type RootCoordServer interface { // @return StringListResponse ShowPartitions(context.Context, *milvuspb.ShowPartitionsRequest) (*milvuspb.ShowPartitionsResponse, error) ShowPartitionsInternal(context.Context, *milvuspb.ShowPartitionsRequest) (*milvuspb.ShowPartitionsResponse, error) - // rpc DescribeSegment(milvus.DescribeSegmentRequest) returns (milvus.DescribeSegmentResponse) {} + // rpc DescribeSegment(milvus.DescribeSegmentRequest) returns (milvus.DescribeSegmentResponse) {} ShowSegments(context.Context, *milvuspb.ShowSegmentsRequest) (*milvuspb.ShowSegmentsResponse, error) AllocTimestamp(context.Context, *AllocTimestampRequest) (*AllocTimestampResponse, error) AllocID(context.Context, *AllocIDRequest) (*AllocIDResponse, error)