When a SearchIteratorParam is initialized via withParams, calling build() raises an error
PiercarloSlavazza opened this issue · 2 comments
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.
@yhmo you are right - closing.