use of org.elasticsearch.search.aggregations.metrics.min.InternalMin in project elasticsearch by elastic.
the class InternalSingleBucketAggregationTestCase method createTestInstance.
@Override
protected final T createTestInstance(String name, List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) {
List<InternalAggregation> internal = new ArrayList<>();
if (hasInternalMax) {
internal.add(new InternalMax("max", randomDouble(), randomFrom(DocValueFormat.BOOLEAN, DocValueFormat.GEOHASH, DocValueFormat.IP, DocValueFormat.RAW), emptyList(), emptyMap()));
}
if (hasInternalMin) {
internal.add(new InternalMin("min", randomDouble(), randomFrom(DocValueFormat.BOOLEAN, DocValueFormat.GEOHASH, DocValueFormat.IP, DocValueFormat.RAW), emptyList(), emptyMap()));
}
// we shouldn't use the full long range here since we sum doc count on reduce, and don't want to overflow the long range there
long docCount = between(0, Integer.MAX_VALUE);
return createTestInstance(name, docCount, new InternalAggregations(internal), pipelineAggregators, metaData);
}
use of org.elasticsearch.search.aggregations.metrics.min.InternalMin in project elasticsearch by elastic.
the class InternalSingleBucketAggregationTestCase method assertReduced.
@Override
protected final void assertReduced(T reduced, List<T> inputs) {
assertEquals(inputs.stream().mapToLong(InternalSingleBucketAggregation::getDocCount).sum(), reduced.getDocCount());
if (hasInternalMax) {
double expected = inputs.stream().mapToDouble(i -> {
InternalMax max = i.getAggregations().get("max");
return max.getValue();
}).max().getAsDouble();
InternalMax reducedMax = reduced.getAggregations().get("max");
assertEquals(expected, reducedMax.getValue(), 0);
}
if (hasInternalMin) {
double expected = inputs.stream().mapToDouble(i -> {
InternalMin min = i.getAggregations().get("min");
return min.getValue();
}).min().getAsDouble();
InternalMin reducedMin = reduced.getAggregations().get("min");
assertEquals(expected, reducedMin.getValue(), 0);
}
extraAssertReduced(reduced, inputs);
}
Aggregations