Support minhash function#1940
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 |
|
Tick the box to add this pull request to the merge queue (same as
|
There was a problem hiding this comment.
Pull request overview
This PR adds SDK-level support for the Milvus MinHash function by extending the client-side FunctionType enum, updating gRPC↔SDK conversion logic, and adding coverage via unit/integration tests plus a runnable example.
Changes:
- Add
MINHASH(andMOLFINGERPRINT) toio.milvus.common.clientenum.FunctionType, and introducefromCode()mapping. - Update
SchemaUtils.convertFromGrpcFunction()to map function types by numeric code instead of proto enum name. - Add MinHash-specific tests (unit + docker integration), update docker image tags, and add a new MinHash example.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk-core/src/main/java/io/milvus/v2/utils/SchemaUtils.java | Switch function-type conversion from name-based mapping to code-based mapping. |
| sdk-core/src/main/java/io/milvus/common/clientenum/FunctionType.java | Extend function types and add code/name conversion helpers. |
| sdk-core/src/test/java/io/milvus/v2/utils/SchemaUtilsTest.java | Add/adjust unit tests for MinHash function conversion. |
| sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java | Add docker integration test that creates/searches with a MinHash function. |
| sdk-core/src/test/java/io/milvus/docker-compose.yml | Update Milvus docker image tag used in tests. |
| sdk-core/src/test/java/io/milvus/docker-compose-multi.yml | Update Milvus docker image tag used in multi-standalone tests. |
| examples/src/main/java/io/milvus/v2/MinhashFunctionExample.java | Add end-to-end MinHash usage example (create, insert, search, dedup-like logic). |
Comments suppressed due to low confidence (1)
sdk-core/src/main/java/io/milvus/common/clientenum/FunctionType.java:63
- FunctionType.fromName()/fromCode() currently return null when no match is found (and fromName(null) will throw NPE). Since this enum already has UNKNOWN, returning UNKNOWN is safer and keeps downstream code (like SchemaUtils conversion/builders) non-null by default.
public static FunctionType fromName(String name) {
for (FunctionType type : FunctionType.values()) {
if (type.getName().equals(name) || type.name().equals(name)) {
return type;
}
}
return null;
}
public static FunctionType fromCode(int code) {
for (FunctionType type : FunctionType.values()) {
if (type.getCode() == code) {
return type;
}
}
return null;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1940 +/- ##
=========================================
Coverage ? 62.99%
Complexity ? 3999
=========================================
Files ? 467
Lines ? 25814
Branches ? 2376
=========================================
Hits ? 16262
Misses ? 8217
Partials ? 1335
🚀 New features to boost your workflow:
|
Signed-off-by: yhmo <yihua.mo@zilliz.com>
| BM25("BM25", 1), | ||
| TEXTEMBEDDING("TextEmbedding", 2), // in milvus-proto, the name is "TextEmbedding" | ||
| RERANK("RERANK", 3); // Added missing name parameter | ||
| RERANK("Rerank", 3), |
There was a problem hiding this comment.
sdk-core/src/main/java/io/milvus/common/clientenum/FunctionType.java line:26
Medium ---- Switching RERANK from "RERANK" to "Rerank" and making fromName() coerce unknown strings to UNKNOWN changes the public FunctionType contract for existing callers, even though the MinHash fix only needs the new fromCode() path in SchemaUtils. Any caller that serialized getName(), looked up fromName("RERANK"), or used null to detect unsupported names will now behave differently; could we keep the old getName()/fromName() semantics and limit this PR to adding MINHASH, MOLFINGERPRINT, and fromCode()?
No description provided.