Skip to content

Commit

Permalink
enhance: Make hasMoreResult accurate when hit number larger than limit (
Browse files Browse the repository at this point in the history
milvus-io#33609)

See also milvus-io/milvus-sdk-go#756

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia committed Jun 5, 2024
1 parent 627b787 commit 05ea172
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion internal/core/src/segcore/InsertRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,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<int64_t> seg_offsets;
seg_offsets.reserve(limit);
Expand All @@ -274,7 +275,7 @@ class OffsetOrderedArray : public OffsetMap {
hit_num++;
}
}
return {seg_offsets, it != array_.end()};
return {seg_offsets, more_hit_than_limit && it != array_.end()};
}

void
Expand Down
4 changes: 2 additions & 2 deletions internal/core/unittest/test_offset_ordered_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 05ea172

Please sign in to comment.