Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/MilvusProtoGen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

include_guard(GLOBAL)

set(PROTO_COMMIT 3c2afcbf9ce6d5c24757d951e530974eabdc5711)
set(PROTO_COMMIT a752bd706b7bf9e2ea7d930d1dff34aa95696ba6)

include(FetchContent)

Expand Down
3 changes: 3 additions & 0 deletions src/impl/types/SearchIteratorV2Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ SearchIteratorV2Impl<T>::next(SingleResultPtr& results) {
if (params.find(ITER_SEARCH_ID_KEY) == params.end()) {
args_.AddExtraParam(ITER_SEARCH_ID_KEY, rpc_results.token());
}
if (!rpc_results.cursor().empty()) {
args_.AddExtraParam(ITER_SEARCH_CURSOR_KEY, rpc_results.cursor());
}

SearchResults search_results;
status = ConvertSearchResults(rpc_response, args_.PkSchema().Name(), search_results);
Expand Down
1 change: 1 addition & 0 deletions src/impl/utils/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const char* ITER_SEARCH_V2_KEY = "search_iter_v2";
const char* ITER_SEARCH_BATCH_SIZE_KEY = "search_iter_batch_size";
const char* ITER_SEARCH_LAST_BOUND_KEY = "search_iter_last_bound";
const char* ITER_SEARCH_ID_KEY = "search_iter_id";
const char* ITER_SEARCH_CURSOR_KEY = "search_iter_cursor";
const char* RERANKER = "reranker";
const char* RANDOM_SCORE = "random_score";

Expand Down
1 change: 1 addition & 0 deletions src/impl/utils/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ extern MILVUS_SDK_API const char* ITER_SEARCH_V2_KEY;
extern MILVUS_SDK_API const char* ITER_SEARCH_BATCH_SIZE_KEY;
extern MILVUS_SDK_API const char* ITER_SEARCH_LAST_BOUND_KEY;
extern MILVUS_SDK_API const char* ITER_SEARCH_ID_KEY;
extern MILVUS_SDK_API const char* ITER_SEARCH_CURSOR_KEY;
extern MILVUS_SDK_API const char* RERANKER;
extern MILVUS_SDK_API const char* RANDOM_SCORE;

Expand Down
12 changes: 12 additions & 0 deletions test/it/v1/TestSearchIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,16 @@ DoSearchIterator(testing::StrictMock<milvus::MilvusMockedService>& service, milv
const int64_t limit = row_count;
uint64_t current_poz = 0;
bool probe_compability = true;
int page_idx = 0;
constexpr uint64_t probe_session_ts = 123456;
EXPECT_CALL(service, Search(_, _, _))
.WillRepeatedly([&](::grpc::ServerContext*, const SearchRequest* request, SearchResults* response) {
auto token = v1 ? "" : "dummy";
response->mutable_results()->mutable_search_iterator_v2_results()->set_token(token);
if (!v1) {
response->mutable_results()->mutable_search_iterator_v2_results()->set_cursor(
"cursor-" + std::to_string(page_idx));
}
if (probe_compability) {
probe_compability = false;
if (!v1) {
Expand All @@ -83,6 +88,8 @@ DoSearchIterator(testing::StrictMock<milvus::MilvusMockedService>& service, milv
}

auto params = request->search_params();
std::string expected_cursor = (!v1 && page_idx > 0) ? ("cursor-" + std::to_string(page_idx)) : "";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/it/v1/TestSearchIterator.cpp line:91
High ---- The mock returns cursor "cursor-<page_idx>", but SearchIteratorV2Impl::next() only echoes the cursor from the PREVIOUS response into the next request. On the second real page (page_idx=1) the request carries "cursor-0" while expected_cursor is "cursor-1", so this EXPECT_EQ fails and testing-it will fail once the "Build and test" CI run is approved. Use "cursor-" + std::to_string(page_idx - 1) (for page_idx > 0) so the assertion matches the previous page's cursor that the iterator actually forwards.

std::string actual_cursor;
for (const auto& pair : params) {
if (pair.key() == milvus::TOPK) {
EXPECT_GE(std::stoul(pair.value()), batch_size);
Expand All @@ -96,7 +103,12 @@ DoSearchIterator(testing::StrictMock<milvus::MilvusMockedService>& service, milv
if (pair.key() == milvus::ITER_SEARCH_BATCH_SIZE_KEY) {
EXPECT_EQ(pair.value(), std::to_string(batch_size));
}
if (pair.key() == milvus::ITER_SEARCH_CURSOR_KEY) {
actual_cursor = pair.value();
}
}
EXPECT_EQ(actual_cursor, expected_cursor);
page_idx++;
EXPECT_THAT(request->output_fields(), UnorderedElementsAreArray(field_names));
EXPECT_EQ(request->collection_name(), collection_name);
EXPECT_EQ(request->consistency_level(), milvus::ConsistencyLevelCast(level));
Expand Down
Loading