From 597f4c5e03d796ac3fbced5ca96101eff6fc91c0 Mon Sep 17 00:00:00 2001 From: congqixia Date: Wed, 5 Jun 2024 11:51:51 +0800 Subject: [PATCH] enhance: Make hasMoreResult accurate when hit number larger than limit (#33609) See also milvus-io/milvus-sdk-go#756 Signed-off-by: Congqi Xia --- internal/core/src/segcore/InsertRecord.h | 3 ++- internal/core/unittest/test_offset_ordered_array.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/core/src/segcore/InsertRecord.h b/internal/core/src/segcore/InsertRecord.h index 13a92d22e7..e4b208bfc2 100644 --- a/internal/core/src/segcore/InsertRecord.h +++ b/internal/core/src/segcore/InsertRecord.h @@ -259,6 +259,7 @@ class OffsetOrderedArray : public OffsetMap { if (!false_filtered_out) { cnt = size - bitset.count(); } + auto more_hit_than_limit = cnt > limit; limit = std::min(limit, cnt); std::vector seg_offsets; seg_offsets.reserve(limit); @@ -275,7 +276,7 @@ class OffsetOrderedArray : public OffsetMap { hit_num++; } } - return {seg_offsets, it != array_.end()}; + return {seg_offsets, more_hit_than_limit && it != array_.end()}; } void diff --git a/internal/core/unittest/test_offset_ordered_array.cpp b/internal/core/unittest/test_offset_ordered_array.cpp index 1eb2e272b0..fd817fbdd5 100644 --- a/internal/core/unittest/test_offset_ordered_array.cpp +++ b/internal/core/unittest/test_offset_ordered_array.cpp @@ -130,10 +130,10 @@ TYPED_TEST_P(TypedOffsetOrderedArrayTest, find_first) { none.reset(); auto result_pair = this->map_.find_first(num / 2, none, true); ASSERT_EQ(0, result_pair.first.size()); - ASSERT_TRUE(result_pair.second); + ASSERT_FALSE(result_pair.second); result_pair = this->map_.find_first(NoLimit, none, true); ASSERT_EQ(0, result_pair.first.size()); - ASSERT_TRUE(result_pair.second); + ASSERT_FALSE(result_pair.second); } }