Add session() interface#1879
Conversation
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
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 andMilvusClientV2Sessionwrapper that copies requests and enforces clusterId consistency. clusterIdfield/builder/toString added toSearchReq,QueryReq,GetReq,HybridSearchReq,QueryIteratorReq,SearchIteratorReq,SearchIteratorReqV2;VectorUtilsand iterators emit it into the right gRPC param list;VectorService.getnow also forwardspartitionNameinto the derivedQueryReq.- New tests in
VectorTest(andBaseTestmock forhybridSearch) 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.
Signed-off-by: yhmo <yihua.mo@zilliz.com>
No description provided.