use of org.elasticsearch.search.aggregations.InternalAggregation in project elasticsearch by elastic.
the class InternalGeoBounds method doReduce.
@Override
public InternalAggregation doReduce(List<InternalAggregation> aggregations, ReduceContext reduceContext) {
double top = Double.NEGATIVE_INFINITY;
double bottom = Double.POSITIVE_INFINITY;
double posLeft = Double.POSITIVE_INFINITY;
double posRight = Double.NEGATIVE_INFINITY;
double negLeft = Double.POSITIVE_INFINITY;
double negRight = Double.NEGATIVE_INFINITY;
for (InternalAggregation aggregation : aggregations) {
InternalGeoBounds bounds = (InternalGeoBounds) aggregation;
if (bounds.top > top) {
top = bounds.top;
}
if (bounds.bottom < bottom) {
bottom = bounds.bottom;
}
if (bounds.posLeft < posLeft) {
posLeft = bounds.posLeft;
}
if (bounds.posRight > posRight) {
posRight = bounds.posRight;
}
if (bounds.negLeft < negLeft) {
negLeft = bounds.negLeft;
}
if (bounds.negRight > negRight) {
negRight = bounds.negRight;
}
}
return new InternalGeoBounds(name, top, bottom, posLeft, posRight, negLeft, negRight, wrapLongitude, pipelineAggregators(), getMetaData());
}
use of org.elasticsearch.search.aggregations.InternalAggregation in project elasticsearch by elastic.
the class AbstractInternalHDRPercentiles method doReduce.
@Override
public AbstractInternalHDRPercentiles doReduce(List<InternalAggregation> aggregations, ReduceContext reduceContext) {
DoubleHistogram merged = null;
for (InternalAggregation aggregation : aggregations) {
final AbstractInternalHDRPercentiles percentiles = (AbstractInternalHDRPercentiles) aggregation;
if (merged == null) {
merged = new DoubleHistogram(percentiles.state);
merged.setAutoResize(true);
}
merged.add(percentiles.state);
}
return createReduced(getName(), keys, merged, keyed, pipelineAggregators(), getMetaData());
}
use of org.elasticsearch.search.aggregations.InternalAggregation in project elasticsearch by elastic.
the class AbstractInternalTDigestPercentiles method doReduce.
@Override
public AbstractInternalTDigestPercentiles doReduce(List<InternalAggregation> aggregations, ReduceContext reduceContext) {
TDigestState merged = null;
for (InternalAggregation aggregation : aggregations) {
final AbstractInternalTDigestPercentiles percentiles = (AbstractInternalTDigestPercentiles) aggregation;
if (merged == null) {
merged = new TDigestState(percentiles.state.compression());
}
merged.add(percentiles.state);
}
return createReduced(getName(), keys, merged, keyed, pipelineAggregators(), getMetaData());
}
use of org.elasticsearch.search.aggregations.InternalAggregation in project elasticsearch by elastic.
the class ProfilingAggregator method buildAggregation.
@Override
public InternalAggregation buildAggregation(long bucket) throws IOException {
profileBreakdown.startTime(AggregationTimingType.BUILD_AGGREGATION);
InternalAggregation result = delegate.buildAggregation(bucket);
profileBreakdown.stopAndRecordTime();
return result;
}
use of org.elasticsearch.search.aggregations.InternalAggregation in project elasticsearch by elastic.
the class SearchModule method registerPipelineAggregation.
private void registerPipelineAggregation(PipelineAggregationSpec spec) {
if (false == transportClient) {
namedXContents.add(new NamedXContentRegistry.Entry(BaseAggregationBuilder.class, spec.getName(), (p, c) -> {
AggregatorFactories.AggParseContext context = (AggregatorFactories.AggParseContext) c;
return spec.getParser().parse(context.name, context.queryParseContext);
}));
}
namedWriteables.add(new NamedWriteableRegistry.Entry(PipelineAggregationBuilder.class, spec.getName().getPreferredName(), spec.getReader()));
namedWriteables.add(new NamedWriteableRegistry.Entry(PipelineAggregator.class, spec.getName().getPreferredName(), spec.getAggregatorReader()));
for (Map.Entry<String, Writeable.Reader<? extends InternalAggregation>> resultReader : spec.getResultReaders().entrySet()) {
namedWriteables.add(new NamedWriteableRegistry.Entry(InternalAggregation.class, resultReader.getKey(), resultReader.getValue()));
}
}
Aggregations