Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
To understand fully about the double and bigdecimal usage in scaled float field will take more time.

Signed-off-by: bowenlan-amzn <[email protected]>
  • Loading branch information
bowenlan-amzn committed Jun 13, 2024
1 parent a2d50ce commit fe85ad3
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit fe85ad3

Please sign in to comment.