Skip to content

Commit c59225f

Browse files
committed
Consistency in using scaled_float field
1 parent 37f9745 commit c59225f

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/ScaledFloatFieldMapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ public BlockLoader blockLoader(BlockLoaderContext blContext) {
312312
return BlockLoader.CONSTANT_NULLS;
313313
}
314314
if (hasDocValues()) {
315-
double scalingFactorInverse = 1d / scalingFactor;
316-
return new BlockDocValuesReader.DoublesBlockLoader(name(), l -> l * scalingFactorInverse);
315+
return new BlockDocValuesReader.DoublesBlockLoader(name(), l -> l / scalingFactor);
317316
}
318317
ValueFetcher valueFetcher = sourceValueFetcher(blContext.sourcePaths(name()));
319318
BlockSourceReader.LeafIteratorLookup lookup = isStored() || isIndexed()

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestUtils.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,6 @@ private static StringBuilder trimOrPad(StringBuilder buffer) {
660660

661661
private static double scaledFloat(String value, String factor) {
662662
double scalingFactor = Double.parseDouble(factor);
663-
// this extra division introduces extra imprecision in the following multiplication, but this is how ScaledFloatFieldMapper works.
664-
double scalingFactorInverse = 1d / scalingFactor;
665-
return new BigDecimal(value).multiply(BigDecimal.valueOf(scalingFactor)).longValue() * scalingFactorInverse;
663+
return new BigDecimal(value).multiply(BigDecimal.valueOf(scalingFactor)).longValue() / scalingFactor;
666664
}
667665
}

0 commit comments

Comments
 (0)