diff --git a/src/main/java/io/milvus/orm/iterator/SearchIterator.java b/src/main/java/io/milvus/orm/iterator/SearchIterator.java index 226da3cca..2b886ff10 100644 --- a/src/main/java/io/milvus/orm/iterator/SearchIterator.java +++ b/src/main/java/io/milvus/orm/iterator/SearchIterator.java @@ -54,7 +54,7 @@ public class SearchIterator { private int cacheId; private boolean initSuccess; private int returnedCount; - private double width; + private float width; private float tailBand; private List filteredIds; @@ -140,8 +140,8 @@ private void checkForSpecialIndexParam() { private void checkRmRangeSearchParameters() { if (params.containsKey(RADIUS) && params.containsKey(RANGE_FILTER)) { - float radius = (float) params.get(RADIUS); - float rangeFilter = (float) params.get(RANGE_FILTER); + float radius = getFloatValue(RADIUS); + float rangeFilter = getFloatValue(RANGE_FILTER); if (metricsPositiveRelated(metricType) && radius <= rangeFilter) { String msg = String.format("for metrics:%s, radius must be larger than range_filter, please adjust your parameter", metricType); ExceptionUtils.throwUnExpectedException(msg); @@ -298,7 +298,7 @@ private void updateWidth(List page) { if (width == 0.0) { // enable a minimum value for width to avoid radius and range_filter equal error - width = 0.05; + width = 0.05f; } } @@ -386,16 +386,16 @@ private Map nextParams(int coefficient) { }); if (metricsPositiveRelated(metricType)) { - double nextRadius = tailBand + width * coefficient; - if (params.containsKey(RADIUS) && nextRadius > (double) params.get(RADIUS)) { - nextParams.put(RADIUS, params.get(RADIUS)); + float nextRadius = tailBand + width * coefficient; + if (params.containsKey(RADIUS) && nextRadius > getFloatValue(RADIUS)) { + nextParams.put(RADIUS, getFloatValue(RADIUS)); } else { nextParams.put(RADIUS, nextRadius); } } else { double nextRadius = tailBand - width * coefficient; - if (params.containsKey(RADIUS) && nextRadius < (double) params.get(RADIUS)) { - nextParams.put(RADIUS, params.get(RADIUS)); + if (params.containsKey(RADIUS) && nextRadius < getFloatValue(RADIUS)) { + nextParams.put(RADIUS, getFloatValue(RADIUS)); } else { nextParams.put(RADIUS, nextRadius); } @@ -457,4 +457,8 @@ private String convertToStr(Object value) { DecimalFormat df = new DecimalFormat("0.0"); return df.format(value); } + + private float getFloatValue(String key) { + return ((Double) params.get(key)).floatValue(); + } }