Search in sources :

Example 1 with ProfilingAggregator

use of org.opensearch.search.profile.aggregation.ProfilingAggregator in project OpenSearch by opensearch-project.

the class AggregatorFactories method createTopLevelAggregators.

public Aggregator[] createTopLevelAggregators(SearchContext searchContext) throws IOException {
    // These aggregators are going to be used with a single bucket ordinal, no need to wrap the PER_BUCKET ones
    Aggregator[] aggregators = new Aggregator[factories.length];
    for (int i = 0; i < factories.length; i++) {
        /*
             * Top level aggs only collect from owningBucketOrd 0 which is
             * *exactly* what CardinalityUpperBound.ONE *means*.
             */
        Aggregator factory = factories[i].create(searchContext, null, CardinalityUpperBound.ONE);
        Profilers profilers = factory.context().getProfilers();
        if (profilers != null) {
            factory = new ProfilingAggregator(factory, profilers.getAggregationProfiler());
        }
        aggregators[i] = factory;
    }
    return aggregators;
}
Also used : ProfilingAggregator(org.opensearch.search.profile.aggregation.ProfilingAggregator) PipelineAggregator(org.opensearch.search.aggregations.pipeline.PipelineAggregator) Profilers(org.opensearch.search.profile.Profilers) ProfilingAggregator(org.opensearch.search.profile.aggregation.ProfilingAggregator)

Example 2 with ProfilingAggregator

use of org.opensearch.search.profile.aggregation.ProfilingAggregator in project OpenSearch by opensearch-project.

the class AggregatorFactories method createSubAggregators.

/**
 * Create all aggregators so that they can be consumed with multiple
 * buckets.
 * @param cardinality Upper bound of the number of {@code owningBucketOrd}s
 *                    that {@link Aggregator}s created by this method will
 *                    be asked to collect.
 */
public Aggregator[] createSubAggregators(SearchContext searchContext, Aggregator parent, CardinalityUpperBound cardinality) throws IOException {
    Aggregator[] aggregators = new Aggregator[countAggregators()];
    for (int i = 0; i < factories.length; ++i) {
        Aggregator factory = factories[i].create(searchContext, parent, cardinality);
        Profilers profilers = factory.context().getProfilers();
        if (profilers != null) {
            factory = new ProfilingAggregator(factory, profilers.getAggregationProfiler());
        }
        aggregators[i] = factory;
    }
    return aggregators;
}
Also used : ProfilingAggregator(org.opensearch.search.profile.aggregation.ProfilingAggregator) PipelineAggregator(org.opensearch.search.aggregations.pipeline.PipelineAggregator) Profilers(org.opensearch.search.profile.Profilers) ProfilingAggregator(org.opensearch.search.profile.aggregation.ProfilingAggregator)

Aggregations

PipelineAggregator (org.opensearch.search.aggregations.pipeline.PipelineAggregator)2 Profilers (org.opensearch.search.profile.Profilers)2 ProfilingAggregator (org.opensearch.search.profile.aggregation.ProfilingAggregator)2