Skip to content

Commit 17ec36e

Browse files
committed
address pr comments
1 parent e04dadd commit 17ec36e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

docs/changelog/128540.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pr: 128540
22
summary: Preserve integer-exact representation of numbers and allow conversion of
3-
floating point values to integers
3+
floating point values to integers in the `convert` ingest processor
44
area: Ingest Node
55
type: enhancement
6-
issues: []
6+
issues:
7+
- 128160

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ConvertProcessor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,18 @@ public static Type fromString(String processorTag, String propertyName, String t
156156
}
157157

158158
private static boolean isExactIntegerFloat(Object value) {
159-
final float ABS_MAX_EXACT_FLOAT = (float) 0x1p24 - 1;
160159
if (value instanceof Float == false) {
161160
return false;
162161
}
163-
float v = ((Float) value).floatValue();
162+
float v = (Float) value;
164163
return v == (long) v && -ABS_MAX_EXACT_FLOAT <= v && v <= ABS_MAX_EXACT_FLOAT;
165164
}
166165

167166
private static boolean isExactIntegerDouble(Object value) {
168-
final double ABS_MAX_EXACT_DOUBLE = 0x1p53 - 1;
169167
if (value instanceof Double == false) {
170168
return false;
171169
}
172-
double v = ((Double) value).doubleValue();
170+
double v = (Double) value;
173171
return v == (long) v && -ABS_MAX_EXACT_DOUBLE <= v && v <= ABS_MAX_EXACT_DOUBLE;
174172
}
175173
}
@@ -181,6 +179,9 @@ private static boolean isExactIntegerDouble(Object value) {
181179
private final Type convertType;
182180
private final boolean ignoreMissing;
183181

182+
private final float ABS_MAX_EXACT_FLOAT = 0x1p24f - 1;
183+
private final double ABS_MAX_EXACT_DOUBLE = 0x1p53 - 1;
184+
184185
ConvertProcessor(String tag, String description, String field, String targetField, Type convertType, boolean ignoreMissing) {
185186
super(tag, description);
186187
this.field = field;

0 commit comments

Comments
 (0)