From de69d51e8b1d7f0e6392a6405590c09afcf806e5 Mon Sep 17 00:00:00 2001 From: fishpenguin Date: Sat, 4 Jul 2020 13:29:52 +0800 Subject: [PATCH] Index type name should returned if index type is not supported Signed-off-by: fishpenguin --- CHANGELOG.md | 1 + core/src/server/ValidationUtil.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99b522ae..2192956a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Please mark all changes in change log and use the issue from GitHub - \#2696 Check the validity of the parameters of creating collection: segment_size - \#2697 Index can not be created - \#2698 Count entities got wrong result with binary vectors +- \#2728 Index type name should returned if index type is not supported - \#2731 No entity returned with `get_entity_by_id` ## Feature diff --git a/core/src/server/ValidationUtil.cpp b/core/src/server/ValidationUtil.cpp index 6debf8e0..08de3286 100644 --- a/core/src/server/ValidationUtil.cpp +++ b/core/src/server/ValidationUtil.cpp @@ -193,8 +193,14 @@ Status ValidateCollectionIndexType(int32_t index_type) { int engine_type = static_cast(engine::EngineType(index_type)); if (engine_type <= 0 || engine_type > static_cast(engine::EngineType::MAX_VALUE)) { - std::string msg = "Invalid index type: " + std::to_string(index_type) + ". " + - "Make sure the index type is in IndexType list."; + std::string index_type_str; + for (auto it = engine::s_map_engine_type.begin(); it != engine::s_map_engine_type.end(); it++) { + if (it->second == (engine::EngineType)index_type) { + index_type_str = it->first; + } + } + std::string msg = + "Invalid index type: " + index_type_str + ". " + "Make sure the index type is in IndexType list."; LOG_SERVER_ERROR_ << msg; return Status(SERVER_INVALID_INDEX_TYPE, msg); } -- GitLab