Skip to content

Support minhash function#1940

Open
yhmo wants to merge 1 commit into
milvus-io:masterfrom
yhmo:ma
Open

Support minhash function#1940
yhmo wants to merge 1 commit into
milvus-io:masterfrom
yhmo:ma

Conversation

@yhmo

@yhmo yhmo commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings July 10, 2026 09:13
@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

@mergify

mergify Bot commented Jul 10, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 (and MOLFINGERPRINT) to io.milvus.common.clientenum.FunctionType, and introduce fromCode() 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.

Comment thread sdk-core/src/main/java/io/milvus/v2/utils/SchemaUtils.java
Comment thread examples/src/main/java/io/milvus/v2/MinhashFunctionExample.java Outdated
Comment thread examples/src/main/java/io/milvus/v2/MinhashFunctionExample.java Outdated
Comment thread examples/src/main/java/io/milvus/v2/MinhashFunctionExample.java Outdated
Comment thread sdk-core/src/test/java/io/milvus/docker-compose.yml
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@00d5f35). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...java/io/milvus/common/clientenum/FunctionType.java 80.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1940   +/-   ##
=========================================
  Coverage          ?   62.99%           
  Complexity        ?     3999           
=========================================
  Files             ?      467           
  Lines             ?    25814           
  Branches          ?     2376           
=========================================
  Hits              ?    16262           
  Misses            ?     8217           
  Partials          ?     1335           
Files with missing lines Coverage Δ
.../src/main/java/io/milvus/v2/utils/SchemaUtils.java 82.11% <100.00%> (ø)
...java/io/milvus/common/clientenum/FunctionType.java 76.19% <80.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify mergify Bot added the ci-passed label Jul 10, 2026
Comment thread sdk-core/src/main/java/io/milvus/v2/utils/SchemaUtils.java Outdated
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),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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()?

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.

4 participants