Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XContentParser shouldn't lose data from floating-point numbers. #46531

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
iter
  • Loading branch information
jpountz committed Sep 10, 2019
commit ed7183581905003572deefadc48381514afd2141
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void testGetDottedValueWithSource() throws Exception {
BytesReference sourceRef = BytesReference.bytes(source);
hit.sourceRef(sourceRef);
Object extract = extractor.extract(hit);
assertFieldHitEquals(hasSource ? value : null, extract);
assertEquals(hasSource ? value : null, extract);
}
}

Expand Down Expand Up @@ -188,7 +188,7 @@ public void testGetSource() throws IOException {
source.endObject();
BytesReference sourceRef = BytesReference.bytes(source);
hit.sourceRef(sourceRef);
assertFieldHitEquals(value, extractor.extract(hit));
assertEquals(value, extractor.extract(hit));
}
}

Expand Down Expand Up @@ -234,7 +234,7 @@ public void testSingleValueArrayInSource() throws IOException {
source.endObject();
BytesReference sourceRef = BytesReference.bytes(source);
hit.sourceRef(sourceRef);
assertFieldHitEquals(value, fe.extract(hit));
assertEquals(value, fe.extract(hit));
}

public void testExtractSourcePath() {
Expand Down Expand Up @@ -605,16 +605,6 @@ private Object randomNonNullValue() {
() -> new BigDecimal("20012312345621343256123456254.20012312345621343256123456254")));
return value.get();
}

private void assertFieldHitEquals(Object expected, Object actual) {
if (expected instanceof BigDecimal) {
// parsing will, by default, build a Double even if the initial value is BigDecimal
// Elasticsearch does this the same when returning the results
assertEquals(((BigDecimal) expected).doubleValue(), actual);
} else {
assertEquals(expected, actual);
}
}

private Object randomPoint(double lat, double lon) {
Supplier<Object> value = randomFrom(Arrays.asList(
Expand Down