From fe85ad3a366c0f5f62827df6f58e4db8542ec40d Mon Sep 17 00:00:00 2001 From: bowenlan-amzn Date: Thu, 13 Jun 2024 10:23:49 -0700 Subject: [PATCH] Fix test To understand fully about the double and bigdecimal usage in scaled float field will take more time. Signed-off-by: bowenlan-amzn --- .../opensearch/index/mapper/ScaledFloatFieldMapper.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/mapper-extras/src/main/java/org/opensearch/index/mapper/ScaledFloatFieldMapper.java b/modules/mapper-extras/src/main/java/org/opensearch/index/mapper/ScaledFloatFieldMapper.java index 91984d3ae768d..3115dce6c10a5 100644 --- a/modules/mapper-extras/src/main/java/org/opensearch/index/mapper/ScaledFloatFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/opensearch/index/mapper/ScaledFloatFieldMapper.java @@ -192,8 +192,15 @@ public ScaledFloatFieldType(String name, double scalingFactor) { @Override public byte[] encodePoint(Number value) { assert value instanceof Double; + double doubleValue = (Double) value; byte[] point = new byte[Long.BYTES]; - LongPoint.encodeDimension(Math.round(scale(value)), point, 0); + if (doubleValue == Double.POSITIVE_INFINITY) { + LongPoint.encodeDimension(Long.MAX_VALUE, point, 0); + } else if (doubleValue == Double.NEGATIVE_INFINITY) { + LongPoint.encodeDimension(Long.MIN_VALUE, point, 0); + } else { + LongPoint.encodeDimension(Math.round(scale(value)), point, 0); + } return point; }