Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When a SearchIteratorParam is initialized via withParams, calling build() raises an error #887

Closed
PiercarloSlavazza opened this issue May 9, 2024 · 2 comments

Comments

@PiercarloSlavazza
Copy link
Contributor

For instance:

SearchIteratorParam.newBuilder()
                .withCollectionName(metadata.getCollectionName())
                .withMetricType(MetricType.IP)
                .withParams("{\"radius\": 0.5, \"range_filter\": 0.8}")

gives the error:

class java.lang.Double cannot be cast to class java.lang.Float (java.lang.Double and java.lang.Float are in module java.base of loader 'bootstrap')

The bug has already been reported and debugged in #881 - quoting explanation from #881 (comment) (Bug n.2):

This bug is actually unrelated to bug n.1 - it just happened to occur while I was trying hard to find a workaround to bug n. 1 (well, before I understood the very nature of that first issue, of course).

In this line:

milvus-sdk-java/src/main/java/io/milvus/orm/iterator/SearchIterator.java

Line 143 in bf981d0
float radius = (float) params.get(RADIUS);

the result of params.get(RADIUS) is cast to a Float - but this leads to a casting error because params.get(RADIUS) is read as a Double, which of course cannot be just cast to a Float. BTW the parameter is read as a Double because this is parsed via JacksonUtils.fromJson(searchIteratorParam.getParams(), new TypeReference<Map<String, Object>>(){}), and Jackson wil always read a real number as a Double in this case, and this behaviour is not - to my knowledge - configurable.

PiercarloSlavazza pushed a commit to PiercarloSlavazza/milvus-sdk-java that referenced this issue May 9, 2024
…rror from Double to float was raised (milvus-io#887)

The error occurred when SearchIterator was created via withParams called with a JSON configured with real numbers - see Issue milvus-io#887 for more details

Signed-off-by: PiercarloSlavazza <[email protected]>
PiercarloSlavazza pushed a commit to PiercarloSlavazza/milvus-sdk-java that referenced this issue May 9, 2024
…rror from Double to float was raised (milvus-io#887)

The error occurred when SearchIterator was created via withParams called with a JSON configured with real numbers - see Issue milvus-io#887 for more details

Signed-off-by: PiercarloSlavazza <[email protected]>
@yhmo
Copy link
Contributor

yhmo commented May 9, 2024

I suppose this bug is fixed by this pr: #884

@PiercarloSlavazza
Copy link
Contributor Author

@yhmo you are right - closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants