Search in sources :

Example 1 with AggregationProfileShardResult

use of org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult in project elasticsearch by elastic.

the class AggregationProfilerIT method testSimpleProfile.

public void testSimpleProfile() {
    SearchResponse response = client().prepareSearch("idx").setProfile(true).addAggregation(histogram("histo").field(NUMBER_FIELD).interval(1L)).get();
    assertSearchResponse(response);
    Map<String, ProfileShardResult> profileResults = response.getProfileResults();
    assertThat(profileResults, notNullValue());
    assertThat(profileResults.size(), equalTo(getNumShards("idx").numPrimaries));
    for (ProfileShardResult profileShardResult : profileResults.values()) {
        assertThat(profileShardResult, notNullValue());
        AggregationProfileShardResult aggProfileResults = profileShardResult.getAggregationProfileResults();
        assertThat(aggProfileResults, notNullValue());
        List<ProfileResult> aggProfileResultsList = aggProfileResults.getProfileResults();
        assertThat(aggProfileResultsList, notNullValue());
        assertThat(aggProfileResultsList.size(), equalTo(1));
        ProfileResult histoAggResult = aggProfileResultsList.get(0);
        assertThat(histoAggResult, notNullValue());
        assertThat(histoAggResult.getQueryName(), equalTo("org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregator"));
        assertThat(histoAggResult.getLuceneDescription(), equalTo("histo"));
        assertThat(histoAggResult.getProfiledChildren().size(), equalTo(0));
        assertThat(histoAggResult.getTime(), greaterThan(0L));
        Map<String, Long> breakdown = histoAggResult.getTimeBreakdown();
        assertThat(breakdown, notNullValue());
        assertThat(breakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(breakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(breakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(breakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(breakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(breakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(breakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(breakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
    }
}
Also used : AggregationProfileShardResult(org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult) ProfileResult(org.elasticsearch.search.profile.ProfileResult) SearchResponse(org.elasticsearch.action.search.SearchResponse) ElasticsearchAssertions.assertSearchResponse(org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse) ProfileShardResult(org.elasticsearch.search.profile.ProfileShardResult) AggregationProfileShardResult(org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult)

Example 2 with AggregationProfileShardResult

use of org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult in project elasticsearch by elastic.

the class AggregationProfilerIT method testMultiLevelProfileBreadthFirst.

public void testMultiLevelProfileBreadthFirst() {
    SearchResponse response = client().prepareSearch("idx").setProfile(true).addAggregation(histogram("histo").field(NUMBER_FIELD).interval(1L).subAggregation(terms("terms").collectMode(SubAggCollectionMode.BREADTH_FIRST).field(TAG_FIELD).subAggregation(avg("avg").field(NUMBER_FIELD)))).get();
    assertSearchResponse(response);
    Map<String, ProfileShardResult> profileResults = response.getProfileResults();
    assertThat(profileResults, notNullValue());
    assertThat(profileResults.size(), equalTo(getNumShards("idx").numPrimaries));
    for (ProfileShardResult profileShardResult : profileResults.values()) {
        assertThat(profileShardResult, notNullValue());
        AggregationProfileShardResult aggProfileResults = profileShardResult.getAggregationProfileResults();
        assertThat(aggProfileResults, notNullValue());
        List<ProfileResult> aggProfileResultsList = aggProfileResults.getProfileResults();
        assertThat(aggProfileResultsList, notNullValue());
        assertThat(aggProfileResultsList.size(), equalTo(1));
        ProfileResult histoAggResult = aggProfileResultsList.get(0);
        assertThat(histoAggResult, notNullValue());
        assertThat(histoAggResult.getQueryName(), equalTo("org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregator"));
        assertThat(histoAggResult.getLuceneDescription(), equalTo("histo"));
        assertThat(histoAggResult.getTime(), greaterThan(0L));
        Map<String, Long> histoBreakdown = histoAggResult.getTimeBreakdown();
        assertThat(histoBreakdown, notNullValue());
        assertThat(histoBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(histoBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(histoBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(histoBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(histoBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(histoBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(histoBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(histoBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(histoAggResult.getProfiledChildren().size(), equalTo(1));
        ProfileResult termsAggResult = histoAggResult.getProfiledChildren().get(0);
        assertThat(termsAggResult, notNullValue());
        assertThat(termsAggResult.getQueryName(), equalTo(GlobalOrdinalsStringTermsAggregator.WithHash.class.getName()));
        assertThat(termsAggResult.getLuceneDescription(), equalTo("terms"));
        assertThat(termsAggResult.getTime(), greaterThan(0L));
        Map<String, Long> termsBreakdown = termsAggResult.getTimeBreakdown();
        assertThat(termsBreakdown, notNullValue());
        assertThat(termsBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(termsBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(termsBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(termsBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(termsBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(termsBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(termsBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(termsBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(termsAggResult.getProfiledChildren().size(), equalTo(1));
        ProfileResult avgAggResult = termsAggResult.getProfiledChildren().get(0);
        assertThat(avgAggResult, notNullValue());
        assertThat(avgAggResult.getQueryName(), equalTo(AvgAggregator.class.getName()));
        assertThat(avgAggResult.getLuceneDescription(), equalTo("avg"));
        assertThat(avgAggResult.getTime(), greaterThan(0L));
        Map<String, Long> avgBreakdown = termsAggResult.getTimeBreakdown();
        assertThat(avgBreakdown, notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(avgAggResult.getProfiledChildren().size(), equalTo(0));
    }
}
Also used : AggregationProfileShardResult(org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult) ProfileResult(org.elasticsearch.search.profile.ProfileResult) GlobalOrdinalsStringTermsAggregator(org.elasticsearch.search.aggregations.bucket.terms.GlobalOrdinalsStringTermsAggregator) SearchResponse(org.elasticsearch.action.search.SearchResponse) ElasticsearchAssertions.assertSearchResponse(org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse) ProfileShardResult(org.elasticsearch.search.profile.ProfileShardResult) AggregationProfileShardResult(org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult)

Example 3 with AggregationProfileShardResult

use of org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult in project elasticsearch by elastic.

the class AggregationProfilerIT method testComplexProfile.

public void testComplexProfile() {
    SearchResponse response = client().prepareSearch("idx").setProfile(true).addAggregation(histogram("histo").field(NUMBER_FIELD).interval(1L).subAggregation(terms("tags").field(TAG_FIELD).subAggregation(avg("avg").field(NUMBER_FIELD)).subAggregation(max("max").field(NUMBER_FIELD))).subAggregation(terms("strings").field(STRING_FIELD).subAggregation(avg("avg").field(NUMBER_FIELD)).subAggregation(max("max").field(NUMBER_FIELD)).subAggregation(terms("tags").field(TAG_FIELD).subAggregation(avg("avg").field(NUMBER_FIELD)).subAggregation(max("max").field(NUMBER_FIELD))))).get();
    assertSearchResponse(response);
    Map<String, ProfileShardResult> profileResults = response.getProfileResults();
    assertThat(profileResults, notNullValue());
    assertThat(profileResults.size(), equalTo(getNumShards("idx").numPrimaries));
    for (ProfileShardResult profileShardResult : profileResults.values()) {
        assertThat(profileShardResult, notNullValue());
        AggregationProfileShardResult aggProfileResults = profileShardResult.getAggregationProfileResults();
        assertThat(aggProfileResults, notNullValue());
        List<ProfileResult> aggProfileResultsList = aggProfileResults.getProfileResults();
        assertThat(aggProfileResultsList, notNullValue());
        assertThat(aggProfileResultsList.size(), equalTo(1));
        ProfileResult histoAggResult = aggProfileResultsList.get(0);
        assertThat(histoAggResult, notNullValue());
        assertThat(histoAggResult.getQueryName(), equalTo("org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregator"));
        assertThat(histoAggResult.getLuceneDescription(), equalTo("histo"));
        assertThat(histoAggResult.getTime(), greaterThan(0L));
        Map<String, Long> histoBreakdown = histoAggResult.getTimeBreakdown();
        assertThat(histoBreakdown, notNullValue());
        assertThat(histoBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(histoBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(histoBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(histoBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(histoBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(histoBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(histoBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(histoBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(histoAggResult.getProfiledChildren().size(), equalTo(2));
        ProfileResult tagsAggResult = histoAggResult.getProfiledChildren().get(0);
        assertThat(tagsAggResult, notNullValue());
        assertThat(tagsAggResult.getQueryName(), equalTo(GlobalOrdinalsStringTermsAggregator.WithHash.class.getName()));
        assertThat(tagsAggResult.getLuceneDescription(), equalTo("tags"));
        assertThat(tagsAggResult.getTime(), greaterThan(0L));
        Map<String, Long> tagsBreakdown = tagsAggResult.getTimeBreakdown();
        assertThat(tagsBreakdown, notNullValue());
        assertThat(tagsBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(tagsBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(tagsBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(tagsBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(tagsBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(tagsBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(tagsBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(tagsBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(tagsAggResult.getProfiledChildren().size(), equalTo(2));
        ProfileResult avgAggResult = tagsAggResult.getProfiledChildren().get(0);
        assertThat(avgAggResult, notNullValue());
        assertThat(avgAggResult.getQueryName(), equalTo(AvgAggregator.class.getName()));
        assertThat(avgAggResult.getLuceneDescription(), equalTo("avg"));
        assertThat(avgAggResult.getTime(), greaterThan(0L));
        Map<String, Long> avgBreakdown = tagsAggResult.getTimeBreakdown();
        assertThat(avgBreakdown, notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(avgAggResult.getProfiledChildren().size(), equalTo(0));
        ProfileResult maxAggResult = tagsAggResult.getProfiledChildren().get(1);
        assertThat(maxAggResult, notNullValue());
        assertThat(maxAggResult.getQueryName(), equalTo(MaxAggregator.class.getName()));
        assertThat(maxAggResult.getLuceneDescription(), equalTo("max"));
        assertThat(maxAggResult.getTime(), greaterThan(0L));
        Map<String, Long> maxBreakdown = tagsAggResult.getTimeBreakdown();
        assertThat(maxBreakdown, notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(maxBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(maxBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(maxBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(maxAggResult.getProfiledChildren().size(), equalTo(0));
        ProfileResult stringsAggResult = histoAggResult.getProfiledChildren().get(1);
        assertThat(stringsAggResult, notNullValue());
        assertThat(stringsAggResult.getQueryName(), equalTo(GlobalOrdinalsStringTermsAggregator.WithHash.class.getName()));
        assertThat(stringsAggResult.getLuceneDescription(), equalTo("strings"));
        assertThat(stringsAggResult.getTime(), greaterThan(0L));
        Map<String, Long> stringsBreakdown = stringsAggResult.getTimeBreakdown();
        assertThat(stringsBreakdown, notNullValue());
        assertThat(stringsBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(stringsBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(stringsBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(stringsBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(stringsBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(stringsBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(stringsBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(stringsBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(stringsAggResult.getProfiledChildren().size(), equalTo(3));
        avgAggResult = stringsAggResult.getProfiledChildren().get(0);
        assertThat(avgAggResult, notNullValue());
        assertThat(avgAggResult.getQueryName(), equalTo(AvgAggregator.class.getName()));
        assertThat(avgAggResult.getLuceneDescription(), equalTo("avg"));
        assertThat(avgAggResult.getTime(), greaterThan(0L));
        avgBreakdown = stringsAggResult.getTimeBreakdown();
        assertThat(avgBreakdown, notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(avgAggResult.getProfiledChildren().size(), equalTo(0));
        maxAggResult = stringsAggResult.getProfiledChildren().get(1);
        assertThat(maxAggResult, notNullValue());
        assertThat(maxAggResult.getQueryName(), equalTo(MaxAggregator.class.getName()));
        assertThat(maxAggResult.getLuceneDescription(), equalTo("max"));
        assertThat(maxAggResult.getTime(), greaterThan(0L));
        maxBreakdown = stringsAggResult.getTimeBreakdown();
        assertThat(maxBreakdown, notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(maxBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(maxBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(maxBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(maxAggResult.getProfiledChildren().size(), equalTo(0));
        tagsAggResult = stringsAggResult.getProfiledChildren().get(2);
        assertThat(tagsAggResult, notNullValue());
        assertThat(tagsAggResult.getQueryName(), equalTo(GlobalOrdinalsStringTermsAggregator.WithHash.class.getName()));
        assertThat(tagsAggResult.getLuceneDescription(), equalTo("tags"));
        assertThat(tagsAggResult.getTime(), greaterThan(0L));
        tagsBreakdown = tagsAggResult.getTimeBreakdown();
        assertThat(tagsBreakdown, notNullValue());
        assertThat(tagsBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(tagsBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(tagsBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(tagsBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(tagsBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(tagsBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(tagsBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(tagsBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(tagsAggResult.getProfiledChildren().size(), equalTo(2));
        avgAggResult = tagsAggResult.getProfiledChildren().get(0);
        assertThat(avgAggResult, notNullValue());
        assertThat(avgAggResult.getQueryName(), equalTo(AvgAggregator.class.getName()));
        assertThat(avgAggResult.getLuceneDescription(), equalTo("avg"));
        assertThat(avgAggResult.getTime(), greaterThan(0L));
        avgBreakdown = tagsAggResult.getTimeBreakdown();
        assertThat(avgBreakdown, notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(avgBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(avgBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(avgAggResult.getProfiledChildren().size(), equalTo(0));
        maxAggResult = tagsAggResult.getProfiledChildren().get(1);
        assertThat(maxAggResult, notNullValue());
        assertThat(maxAggResult.getQueryName(), equalTo(MaxAggregator.class.getName()));
        assertThat(maxAggResult.getLuceneDescription(), equalTo("max"));
        assertThat(maxAggResult.getTime(), greaterThan(0L));
        maxBreakdown = tagsAggResult.getTimeBreakdown();
        assertThat(maxBreakdown, notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.INITIALIZE.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.INITIALIZE.toString()), greaterThan(0L));
        assertThat(maxBreakdown.get(AggregationTimingType.COLLECT.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.COLLECT.toString()), greaterThan(0L));
        assertThat(maxBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.BUILD_AGGREGATION.toString()), greaterThan(0L));
        assertThat(maxBreakdown.get(AggregationTimingType.REDUCE.toString()), notNullValue());
        assertThat(maxBreakdown.get(AggregationTimingType.REDUCE.toString()), equalTo(0L));
        assertThat(maxAggResult.getProfiledChildren().size(), equalTo(0));
    }
}
Also used : AggregationProfileShardResult(org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult) ProfileResult(org.elasticsearch.search.profile.ProfileResult) GlobalOrdinalsStringTermsAggregator(org.elasticsearch.search.aggregations.bucket.terms.GlobalOrdinalsStringTermsAggregator) SearchResponse(org.elasticsearch.action.search.SearchResponse) ElasticsearchAssertions.assertSearchResponse(org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse) ProfileShardResult(org.elasticsearch.search.profile.ProfileShardResult) AggregationProfileShardResult(org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult)

Example 4 with AggregationProfileShardResult

use of org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult in project elasticsearch by elastic.

the class SearchProfileShardResults method buildShardResults.

/**
     * Helper method to convert Profiler into InternalProfileShardResults, which
     * can be serialized to other nodes, emitted as JSON, etc.
     *
     * @param profilers
     *            The {@link Profilers} to convert into results
     * @return A {@link ProfileShardResult} representing the results for this
     *         shard
     */
public static ProfileShardResult buildShardResults(Profilers profilers) {
    List<QueryProfiler> queryProfilers = profilers.getQueryProfilers();
    AggregationProfiler aggProfiler = profilers.getAggregationProfiler();
    List<QueryProfileShardResult> queryResults = new ArrayList<>(queryProfilers.size());
    for (QueryProfiler queryProfiler : queryProfilers) {
        QueryProfileShardResult result = new QueryProfileShardResult(queryProfiler.getTree(), queryProfiler.getRewriteTime(), queryProfiler.getCollector());
        queryResults.add(result);
    }
    AggregationProfileShardResult aggResults = new AggregationProfileShardResult(aggProfiler.getTree());
    return new ProfileShardResult(queryResults, aggResults);
}
Also used : AggregationProfileShardResult(org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult) QueryProfileShardResult(org.elasticsearch.search.profile.query.QueryProfileShardResult) AggregationProfiler(org.elasticsearch.search.profile.aggregation.AggregationProfiler) ArrayList(java.util.ArrayList) QueryProfiler(org.elasticsearch.search.profile.query.QueryProfiler) QueryProfileShardResult(org.elasticsearch.search.profile.query.QueryProfileShardResult) AggregationProfileShardResult(org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult)

Example 5 with AggregationProfileShardResult

use of org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult in project elasticsearch by elastic.

the class SearchProfileShardResults method parseSearchProfileResultsEntry.

private static void parseSearchProfileResultsEntry(XContentParser parser, Map<String, ProfileShardResult> searchProfileResults) throws IOException {
    XContentParser.Token token = parser.currentToken();
    ensureExpectedToken(XContentParser.Token.START_OBJECT, token, parser::getTokenLocation);
    List<QueryProfileShardResult> queryProfileResults = new ArrayList<>();
    AggregationProfileShardResult aggProfileShardResult = null;
    String id = null;
    String currentFieldName = null;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (token.isValue()) {
            if (ID_FIELD.equals(currentFieldName)) {
                id = parser.text();
            } else {
                throwUnknownField(currentFieldName, parser.getTokenLocation());
            }
        } else if (token == XContentParser.Token.START_ARRAY) {
            if (SEARCHES_FIELD.equals(currentFieldName)) {
                while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
                    queryProfileResults.add(QueryProfileShardResult.fromXContent(parser));
                }
            } else if (AggregationProfileShardResult.AGGREGATIONS.equals(currentFieldName)) {
                aggProfileShardResult = AggregationProfileShardResult.fromXContent(parser);
            } else {
                throwUnknownField(currentFieldName, parser.getTokenLocation());
            }
        } else {
            throwUnknownToken(token, parser.getTokenLocation());
        }
    }
    searchProfileResults.put(id, new ProfileShardResult(queryProfileResults, aggProfileShardResult));
}
Also used : AggregationProfileShardResult(org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult) QueryProfileShardResult(org.elasticsearch.search.profile.query.QueryProfileShardResult) ArrayList(java.util.ArrayList) XContentParser(org.elasticsearch.common.xcontent.XContentParser) QueryProfileShardResult(org.elasticsearch.search.profile.query.QueryProfileShardResult) AggregationProfileShardResult(org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult)

Aggregations

AggregationProfileShardResult (org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult)8 SearchResponse (org.elasticsearch.action.search.SearchResponse)5 ProfileResult (org.elasticsearch.search.profile.ProfileResult)5 ProfileShardResult (org.elasticsearch.search.profile.ProfileShardResult)5 ElasticsearchAssertions.assertSearchResponse (org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)5 ArrayList (java.util.ArrayList)3 GlobalOrdinalsStringTermsAggregator (org.elasticsearch.search.aggregations.bucket.terms.GlobalOrdinalsStringTermsAggregator)3 QueryProfileShardResult (org.elasticsearch.search.profile.query.QueryProfileShardResult)3 HashMap (java.util.HashMap)1 XContentParser (org.elasticsearch.common.xcontent.XContentParser)1 AggregationProfiler (org.elasticsearch.search.profile.aggregation.AggregationProfiler)1 QueryProfiler (org.elasticsearch.search.profile.query.QueryProfiler)1