From daf51a95d9186fcbfcfb1a8e557cbb284d713287 Mon Sep 17 00:00:00 2001 From: Ji Bin Date: Mon, 15 Jan 2024 19:26:44 +0800 Subject: [PATCH] fix: fix ShowPartitions error, #246 (#250) --- src/impl/MilvusClientImpl.cpp | 6 +++++- test/st/TestCollection.cpp | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/impl/MilvusClientImpl.cpp b/src/impl/MilvusClientImpl.cpp index 38c8a8f..db66182 100644 --- a/src/impl/MilvusClientImpl.cpp +++ b/src/impl/MilvusClientImpl.cpp @@ -423,8 +423,12 @@ MilvusClientImpl::ShowPartitions(const std::string& collection_name, const std:: partitions_info.reserve(count); } for (int i = 0; i < count; ++i) { + int inmemory_percentage = 0; + if (response.inmemory_percentages_size() > i) { + inmemory_percentage = response.inmemory_percentages(i); + } partitions_info.emplace_back(response.partition_names(i), response.partitionids(i), - response.created_timestamps(i), response.inmemory_percentages(i)); + response.created_timestamps(i), inmemory_percentage); } }; diff --git a/test/st/TestCollection.cpp b/test/st/TestCollection.cpp index 482abb8..e960ad3 100644 --- a/test/st/TestCollection.cpp +++ b/test/st/TestCollection.cpp @@ -56,6 +56,11 @@ TEST_P(MilvusServerTestCollection, CreateAndDeleteCollection) { EXPECT_EQ(collection_infos.front().MemoryPercentage(), 0); EXPECT_EQ(collection_infos.front().Name(), "Foo"); + // test for https://github.com/milvus-io/milvus-sdk-cpp/issues/246 + milvus::PartitionsInfo partitionsInfo{}; + status = client_->ShowPartitions("Foo", std::vector{}, partitionsInfo); + EXPECT_TRUE(status.IsOk()); + names.emplace_back("Foo"); collection_infos.clear(); status = client_->LoadCollection("Foo");