mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-29 06:55:27 +08:00
* Fix show partitions failed in http module (fix #2228) Signed-off-by: yhz <413554850@qq.com> * catch json string convert error Signed-off-by: yhz <413554850@qq.com>
This commit is contained in:
parent
e63904867b
commit
8d732656a7
@ -24,6 +24,7 @@ Please mark all change in change log and use the issue from GitHub
|
||||
- \#2194 Fix get collection info failed
|
||||
- \#2196 Fix server start failed if wal is disabled
|
||||
- \#2203 0.8.0 id=-1 is returned when total count < topk
|
||||
- \#2228 Fix show partitions failed in http module
|
||||
- \#2231 Use server_config to define hard-delete delay time for segment files
|
||||
- \#2261 Re-define result returned by has_collection if collection in delete state
|
||||
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
#include <oatpp/network/client/SimpleTCPConnectionProvider.hpp>
|
||||
#include <oatpp/network/server/SimpleTCPConnectionProvider.hpp>
|
||||
#include <oatpp/parser/json/mapping/Deserializer.hpp>
|
||||
#include <oatpp/parser/json/mapping/Serializer.hpp>
|
||||
#include <oatpp/parser/json/mapping/ObjectMapper.hpp>
|
||||
#include <oatpp/parser/json/mapping/Serializer.hpp>
|
||||
#include <oatpp/web/server/HttpConnectionHandler.hpp>
|
||||
#include <oatpp/web/server/HttpRouter.hpp>
|
||||
|
||||
|
||||
@ -1457,7 +1457,35 @@ WebRequestHandler::ShowSegments(const OString& collection_name, const OQueryPara
|
||||
ASSIGN_RETURN_STATUS_DTO(status)
|
||||
}
|
||||
|
||||
nlohmann::json result_json = nlohmann::json::parse(info);
|
||||
nlohmann::json info_json = nlohmann::json::parse(info);
|
||||
nlohmann::json segments_json = nlohmann::json::array();
|
||||
for (auto& par : info_json["partitions"]) {
|
||||
if (!(all_required || tag.empty() || tag == par["tag"])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto segments = par["segments"];
|
||||
if (!segments.is_null()) {
|
||||
for (auto& seg : segments) {
|
||||
seg["partition_tag"] = par["tag"];
|
||||
segments_json.push_back(seg);
|
||||
}
|
||||
}
|
||||
}
|
||||
nlohmann::json result_json;
|
||||
if (!all_required) {
|
||||
int64_t size = segments_json.size();
|
||||
int iter_begin = std::min(size, offset);
|
||||
int iter_end = std::min(size, offset + page_size);
|
||||
|
||||
nlohmann::json segments_slice_json = nlohmann::json::array();
|
||||
segments_slice_json.insert(segments_slice_json.begin(), segments_json.begin() + iter_begin,
|
||||
segments_json.begin() + iter_end);
|
||||
result_json["segments"] = segments_slice_json; // segments_json;
|
||||
} else {
|
||||
result_json["segments"] = segments_json;
|
||||
}
|
||||
result_json["count"] = segments_json.size();
|
||||
AddStatusToJson(result_json, status.code(), status.message());
|
||||
response = result_json.dump().c_str();
|
||||
|
||||
@ -1535,9 +1563,14 @@ WebRequestHandler::Insert(const OString& collection_name, const OString& body, V
|
||||
}
|
||||
auto& id_array = vectors.id_array_;
|
||||
id_array.clear();
|
||||
for (auto& id_str : ids_json) {
|
||||
int64_t id = std::stol(id_str.get<std::string>());
|
||||
id_array.emplace_back(id);
|
||||
try {
|
||||
for (auto& id_str : ids_json) {
|
||||
int64_t id = std::stol(id_str.get<std::string>());
|
||||
id_array.emplace_back(id);
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
std::string err_msg = std::string("Cannot convert vectors id. details: ") + e.what();
|
||||
RETURN_STATUS_DTO(SERVER_UNEXPECTED_ERROR, err_msg.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
core/thirdparty/versions.txt
vendored
2
core/thirdparty/versions.txt
vendored
@ -11,7 +11,7 @@ GRPC_VERSION=master
|
||||
ZLIB_VERSION=v1.2.11
|
||||
OPENTRACING_VERSION=v1.5.1
|
||||
FIU_VERSION=1.00
|
||||
OATPP_VERSION=1.0.0
|
||||
OATPP_VERSION=1.0.1
|
||||
AWS_VERSION=1.7.250
|
||||
|
||||
# vim: set filetype=sh:
|
||||
|
||||
@ -1026,11 +1026,12 @@ TEST_F(WebControllerTest, SHOW_SEGMENTS) {
|
||||
std::string json_str = response->readBodyToString()->c_str();
|
||||
auto result_json = nlohmann::json::parse(json_str);
|
||||
|
||||
ASSERT_TRUE(result_json.contains("row_count"));
|
||||
|
||||
ASSERT_TRUE(result_json.contains("partitions"));
|
||||
auto segments_json = result_json["partitions"];
|
||||
ASSERT_TRUE(result_json.contains("count"));
|
||||
ASSERT_TRUE(result_json.contains("segments"));
|
||||
auto segments_json = result_json["segments"];
|
||||
ASSERT_TRUE(segments_json.is_array());
|
||||
auto seg0_json = segments_json[0];
|
||||
ASSERT_TRUE(seg0_json.contains("partition_tag"));
|
||||
// ASSERT_EQ(10, segments_json.size());
|
||||
}
|
||||
|
||||
@ -1049,7 +1050,7 @@ TEST_F(WebControllerTest, GET_SEGMENT_INFO) {
|
||||
std::string json_str = response->readBodyToString()->c_str();
|
||||
auto result_json = nlohmann::json::parse(json_str);
|
||||
|
||||
auto segment0_json = result_json["partitions"][0]["segments"][0];
|
||||
auto segment0_json = result_json["segments"][0];
|
||||
std::string segment_name = segment0_json["name"];
|
||||
|
||||
// get segment ids
|
||||
@ -1104,15 +1105,15 @@ TEST_F(WebControllerTest, SEGMENT_FILTER) {
|
||||
|
||||
std::string json_str = response->readBodyToString()->c_str();
|
||||
auto result_json = nlohmann::json::parse(json_str);
|
||||
ASSERT_TRUE(result_json.contains("row_count"));
|
||||
ASSERT_TRUE(result_json.contains("count"));
|
||||
|
||||
ASSERT_TRUE(result_json.contains("partitions"));
|
||||
auto partitions_json = result_json["partitions"];
|
||||
ASSERT_TRUE(partitions_json.is_array());
|
||||
for (auto& part : partitions_json) {
|
||||
ASSERT_TRUE(part.contains("tag"));
|
||||
ASSERT_TRUE(result_json.contains("segments"));
|
||||
auto segments_json = result_json["segments"];
|
||||
ASSERT_TRUE(segments_json.is_array());
|
||||
for (auto& part : segments_json) {
|
||||
ASSERT_TRUE(part.contains("partition_tag"));
|
||||
}
|
||||
ASSERT_EQ("_default", partitions_json[0]["tag"].get<std::string>());
|
||||
ASSERT_EQ("_default", segments_json[0]["partition_tag"].get<std::string>());
|
||||
}
|
||||
|
||||
TEST_F(WebControllerTest, SEARCH) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user