Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,6 @@ tests:
- class: org.elasticsearch.xpack.security.authc.jwt.JwtRealmAuthenticateTests
method: testJwkUpdatesByReloadWithFile
issue: https://github.com/elastic/elasticsearch/issues/138397
- class: org.elasticsearch.compute.data.ExponentialHistogramBlockTests
method: testComponentAccess
issue: https://github.com/elastic/elasticsearch/issues/138399

# Examples:
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,31 @@ public class ExponentialHistogramParserTests extends ESTestCase {
private static final String TEST_FIELD_NAME = "test_field";

public void testParseRandomHistogram() throws IOException {
ExponentialHistogram histogram = ExponentialHistogramTestUtils.randomHistogram();
for (int i = 0; i < 20; i++) {
ExponentialHistogram histogram = ExponentialHistogramTestUtils.randomHistogram();

ExponentialHistogramParser.ParsedExponentialHistogram parsed;
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
ExponentialHistogramXContent.serialize(builder, histogram);
String json = Strings.toString(builder);
parsed = doParse(json);
}
ExponentialHistogramParser.ParsedExponentialHistogram parsed;
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
ExponentialHistogramXContent.serialize(builder, histogram);
String json = Strings.toString(builder);
parsed = doParse(json);
}

List<IndexWithCount> expectedPositiveBuckets = IndexWithCount.fromIterator(histogram.positiveBuckets().iterator());
List<IndexWithCount> expectedNegativeBuckets = IndexWithCount.fromIterator(histogram.negativeBuckets().iterator());
List<IndexWithCount> expectedPositiveBuckets = IndexWithCount.fromIterator(histogram.positiveBuckets().iterator());
List<IndexWithCount> expectedNegativeBuckets = IndexWithCount.fromIterator(histogram.negativeBuckets().iterator());

assertThat(parsed.scale(), equalTo(histogram.scale()));
assertThat(parsed.scale(), equalTo(histogram.scale()));

assertThat(parsed.zeroThreshold(), equalTo(histogram.zeroBucket().zeroThreshold()));
assertThat(parsed.zeroCount(), equalTo(histogram.zeroBucket().count()));
assertThat(parsed.zeroThreshold(), equalTo(histogram.zeroBucket().zeroThreshold()));
assertThat(parsed.zeroCount(), equalTo(histogram.zeroBucket().count()));

assertThat(parsed.positiveBuckets(), equalTo(expectedPositiveBuckets));
assertThat(parsed.negativeBuckets(), equalTo(expectedNegativeBuckets));
assertThat(parsed.positiveBuckets(), equalTo(expectedPositiveBuckets));
assertThat(parsed.negativeBuckets(), equalTo(expectedNegativeBuckets));

assertThat(parsed.sum(), equalTo(histogram.sum()));
assertThat(parsed.min(), equalTo(Double.isNaN(histogram.min()) ? null : histogram.min()));
assertThat(parsed.max(), equalTo(Double.isNaN(histogram.max()) ? null : histogram.max()));
assertThat(parsed.sum(), equalTo(histogram.valueCount() == 0 ? null : histogram.sum()));
assertThat(parsed.min(), equalTo(Double.isNaN(histogram.min()) ? null : histogram.min()));
assertThat(parsed.max(), equalTo(Double.isNaN(histogram.max()) ? null : histogram.max()));
}
}

public void testParseScaleMissing() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ public void testComponentAccess() {
}
}
case SUM -> {
assertThat(componentBlock.getValueCount(i), equalTo(1));
int valueIndex = componentBlock.getFirstValueIndex(i);
assertThat(((DoubleBlock) componentBlock).getDouble(valueIndex), equalTo(histo.sum()));
if (histo.valueCount() == 0) {
assertThat(componentBlock.isNull(i), equalTo(true));
} else {
assertThat(componentBlock.getValueCount(i), equalTo(1));
int valueIndex = componentBlock.getFirstValueIndex(i);
assertThat(((DoubleBlock) componentBlock).getDouble(valueIndex), equalTo(histo.sum()));
}
}
case COUNT -> {
assertThat(componentBlock.getValueCount(i), equalTo(1));
Expand Down