Skip to content

Add session() interface#1879

Merged
sre-ci-robot merged 1 commit into
milvus-io:masterfrom
yhmo:mm
Jun 1, 2026
Merged

Add session() interface#1879
sre-ci-robot merged 1 commit into
milvus-io:masterfrom
yhmo:mm

Conversation

@yhmo
Copy link
Copy Markdown
Contributor

@yhmo yhmo commented Jun 1, 2026

No description provided.

Copilot AI review requested due to automatic review settings June 1, 2026 03:32
@sre-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yhmo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a session-style API to MilvusClientV2 that binds vector/read requests to a specific cluster within a global-cluster deployment. Calling client.session(clusterId) returns a MilvusClientV2Session that wraps search, hybridSearch, query, get, and the three iterator APIs; each call makes a defensive copy of the request, stamps the session's clusterId, and rejects conflicting cluster IDs or use after close(). The clusterId is then propagated into gRPC requests as a cluster_id KV in queryParams (query/get/queryIterator), searchParams (search/searchIterator), or rankParams (hybridSearch).

Changes:

  • New MilvusClientV2.session(String clusterId) factory and MilvusClientV2Session wrapper that copies requests and enforces clusterId consistency.
  • clusterId field/builder/toString added to SearchReq, QueryReq, GetReq, HybridSearchReq, QueryIteratorReq, SearchIteratorReq, SearchIteratorReqV2; VectorUtils and iterators emit it into the right gRPC param list; VectorService.get now also forwards partitionName into the derived QueryReq.
  • New tests in VectorTest (and BaseTest mock for hybridSearch) verifying cluster_id placement and rejection of closed sessions / conflicting cluster IDs.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java Adds session(clusterId) factory with empty-input validation.
sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2Session.java New wrapper class; copies each supported request and sets clusterId.
sdk-core/src/main/java/io/milvus/v2/service/vector/request/{SearchReq,QueryReq,GetReq,HybridSearchReq,QueryIteratorReq,SearchIteratorReq,SearchIteratorReqV2}.java Adds clusterId field, accessors, builder, and toString entry.
sdk-core/src/main/java/io/milvus/v2/utils/VectorUtils.java Adds CLUSTER_ID constant and writes cluster_id into query/search/rank params.
sdk-core/src/main/java/io/milvus/v2/service/vector/VectorService.java get forwards clusterId and partitionName into the derived QueryReq.
sdk-core/src/main/java/io/milvus/orm/iterator/QueryIterator.java Propagates clusterId from QueryIteratorReq into the internal QueryReq.
sdk-core/src/main/java/io/milvus/orm/iterator/SearchIteratorV2.java Propagates clusterId from SearchIteratorReqV2 into the internal SearchReq.
sdk-core/src/main/java/io/milvus/orm/iterator/SearchIterator.java Stores clusterId and appends a cluster_id KV to search params directly.
sdk-core/src/test/java/io/milvus/v2/BaseTest.java Mocks blockingStub.hybridSearch to enable hybrid-search tests.
sdk-core/src/test/java/io/milvus/v2/service/vector/VectorTest.java New tests verifying session-injected cluster_id and conflict/closed handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk-core/src/main/java/io/milvus/orm/iterator/SearchIterator.java
Signed-off-by: yhmo <yihua.mo@zilliz.com>
@mergify mergify Bot added ci-passed and removed ci-passed labels Jun 1, 2026
@yhmo yhmo added the lgtm label Jun 1, 2026
@sre-ci-robot sre-ci-robot merged commit a873189 into milvus-io:master Jun 1, 2026
6 checks passed
@yhmo yhmo deleted the mm branch June 1, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants