diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java b/core/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java index 4953a39d4b5..f3ad47910e4 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java @@ -30,8 +30,8 @@ import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.pipeline.SiblingPipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.internal.SearchContext; -import org.elasticsearch.search.profile.CollectorResult; -import org.elasticsearch.search.profile.InternalProfileCollector; +import org.elasticsearch.search.profile.query.CollectorResult; +import org.elasticsearch.search.profile.query.InternalProfileCollector; import org.elasticsearch.search.query.QueryPhaseExecutionException; import java.io.IOException; @@ -125,7 +125,7 @@ public class AggregationPhase implements SearchPhase { Collections.emptyList()); collector = profileCollector; // start a new profile with this collector - context.getProfilers().addProfiler().setCollector(profileCollector); + context.getProfilers().addQueryProfiler().setCollector(profileCollector); } globalsCollector.preCollection(); context.searcher().search(query, collector); diff --git a/core/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java b/core/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java index 471ce26d297..df1007ebc71 100644 --- a/core/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java +++ b/core/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java @@ -33,10 +33,10 @@ import org.apache.lucene.search.Weight; import org.elasticsearch.common.lease.Releasable; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.search.dfs.AggregatedDfs; -import org.elasticsearch.search.profile.QueryProfileBreakdown; -import org.elasticsearch.search.profile.ProfileWeight; -import org.elasticsearch.search.profile.QueryProfiler; -import org.elasticsearch.search.profile.QueryTimingType; +import org.elasticsearch.search.profile.query.ProfileWeight; +import org.elasticsearch.search.profile.query.QueryProfileBreakdown; +import org.elasticsearch.search.profile.query.QueryProfiler; +import org.elasticsearch.search.profile.query.QueryTimingType; import java.io.IOException; diff --git a/core/src/main/java/org/elasticsearch/search/profile/ProfileResult.java b/core/src/main/java/org/elasticsearch/search/profile/ProfileResult.java index 165244e8d69..4c745a5127d 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/ProfileResult.java +++ b/core/src/main/java/org/elasticsearch/search/profile/ProfileResult.java @@ -43,7 +43,7 @@ import java.util.Map; * Each InternalProfileResult has a List of InternalProfileResults, which will contain * "children" queries if applicable */ -final class ProfileResult implements Writeable, ToXContent { +public final class ProfileResult implements Writeable, ToXContent { private static final ParseField TYPE = new ParseField("type"); private static final ParseField DESCRIPTION = new ParseField("description"); diff --git a/core/src/main/java/org/elasticsearch/search/profile/ProfileShardResult.java b/core/src/main/java/org/elasticsearch/search/profile/ProfileShardResult.java index e35a3c2e2aa..9def3db7582 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/ProfileShardResult.java +++ b/core/src/main/java/org/elasticsearch/search/profile/ProfileShardResult.java @@ -24,6 +24,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.search.profile.query.CollectorResult; import java.io.IOException; import java.util.ArrayList; diff --git a/core/src/main/java/org/elasticsearch/search/profile/Profilers.java b/core/src/main/java/org/elasticsearch/search/profile/Profilers.java index 38b69d38b15..e9e6d88db18 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/Profilers.java +++ b/core/src/main/java/org/elasticsearch/search/profile/Profilers.java @@ -20,6 +20,7 @@ package org.elasticsearch.search.profile; import org.elasticsearch.search.internal.ContextIndexSearcher; +import org.elasticsearch.search.profile.query.QueryProfiler; import java.util.ArrayList; import java.util.Collections; @@ -29,31 +30,31 @@ import java.util.List; public final class Profilers { private final ContextIndexSearcher searcher; - private final List profilers; + private final List queryProfilers; /** Sole constructor. This {@link Profilers} instance will initially wrap one {@link QueryProfiler}. */ public Profilers(ContextIndexSearcher searcher) { this.searcher = searcher; - this.profilers = new ArrayList<>(); - addProfiler(); + this.queryProfilers = new ArrayList<>(); + addQueryProfiler(); } /** Switch to a new profile. */ - public QueryProfiler addProfiler() { + public QueryProfiler addQueryProfiler() { QueryProfiler profiler = new QueryProfiler(); searcher.setProfiler(profiler); - profilers.add(profiler); + queryProfilers.add(profiler); return profiler; } /** Get the current profiler. */ - public QueryProfiler getCurrent() { - return profilers.get(profilers.size() - 1); + public QueryProfiler getCurrentQueryProfiler() { + return queryProfilers.get(queryProfilers.size() - 1); } /** Return the list of all created {@link QueryProfiler}s so far. */ - public List getProfilers() { - return Collections.unmodifiableList(profilers); + public List getQueryProfilers() { + return Collections.unmodifiableList(queryProfilers); } } diff --git a/core/src/main/java/org/elasticsearch/search/profile/SearchProfileShardResults.java b/core/src/main/java/org/elasticsearch/search/profile/SearchProfileShardResults.java index a38c0813dc5..bf265dd9a7e 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/SearchProfileShardResults.java +++ b/core/src/main/java/org/elasticsearch/search/profile/SearchProfileShardResults.java @@ -24,6 +24,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.search.profile.query.QueryProfiler; import java.io.IOException; import java.util.ArrayList; diff --git a/core/src/main/java/org/elasticsearch/search/profile/CollectorResult.java b/core/src/main/java/org/elasticsearch/search/profile/query/CollectorResult.java similarity index 99% rename from core/src/main/java/org/elasticsearch/search/profile/CollectorResult.java rename to core/src/main/java/org/elasticsearch/search/profile/query/CollectorResult.java index 32b9ccfa942..c517c8730e4 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/CollectorResult.java +++ b/core/src/main/java/org/elasticsearch/search/profile/query/CollectorResult.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; diff --git a/core/src/main/java/org/elasticsearch/search/profile/InternalProfileCollector.java b/core/src/main/java/org/elasticsearch/search/profile/query/InternalProfileCollector.java similarity index 98% rename from core/src/main/java/org/elasticsearch/search/profile/InternalProfileCollector.java rename to core/src/main/java/org/elasticsearch/search/profile/query/InternalProfileCollector.java index 48d165e3095..e892abaab22 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/InternalProfileCollector.java +++ b/core/src/main/java/org/elasticsearch/search/profile/query/InternalProfileCollector.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Collector; diff --git a/core/src/main/java/org/elasticsearch/search/profile/InternalQueryProfileTree.java b/core/src/main/java/org/elasticsearch/search/profile/query/InternalQueryProfileTree.java similarity index 98% rename from core/src/main/java/org/elasticsearch/search/profile/InternalQueryProfileTree.java rename to core/src/main/java/org/elasticsearch/search/profile/query/InternalQueryProfileTree.java index 9ebee2f1635..5b92ef8b2a9 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/InternalQueryProfileTree.java +++ b/core/src/main/java/org/elasticsearch/search/profile/query/InternalQueryProfileTree.java @@ -17,9 +17,10 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; import org.apache.lucene.search.Query; +import org.elasticsearch.search.profile.ProfileResult; import java.util.ArrayList; import java.util.Collections; diff --git a/core/src/main/java/org/elasticsearch/search/profile/ProfileCollector.java b/core/src/main/java/org/elasticsearch/search/profile/query/ProfileCollector.java similarity index 98% rename from core/src/main/java/org/elasticsearch/search/profile/ProfileCollector.java rename to core/src/main/java/org/elasticsearch/search/profile/query/ProfileCollector.java index 7d7538c9117..c65d0978906 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/ProfileCollector.java +++ b/core/src/main/java/org/elasticsearch/search/profile/query/ProfileCollector.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Collector; diff --git a/core/src/main/java/org/elasticsearch/search/profile/ProfileScorer.java b/core/src/main/java/org/elasticsearch/search/profile/query/ProfileScorer.java similarity index 99% rename from core/src/main/java/org/elasticsearch/search/profile/ProfileScorer.java rename to core/src/main/java/org/elasticsearch/search/profile/query/ProfileScorer.java index 939ac85c871..51d0b14fc96 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/ProfileScorer.java +++ b/core/src/main/java/org/elasticsearch/search/profile/query/ProfileScorer.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.Scorer; diff --git a/core/src/main/java/org/elasticsearch/search/profile/ProfileWeight.java b/core/src/main/java/org/elasticsearch/search/profile/query/ProfileWeight.java similarity index 98% rename from core/src/main/java/org/elasticsearch/search/profile/ProfileWeight.java rename to core/src/main/java/org/elasticsearch/search/profile/query/ProfileWeight.java index 9546f691616..9ca33f84542 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/ProfileWeight.java +++ b/core/src/main/java/org/elasticsearch/search/profile/query/ProfileWeight.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; diff --git a/core/src/main/java/org/elasticsearch/search/profile/QueryProfileBreakdown.java b/core/src/main/java/org/elasticsearch/search/profile/query/QueryProfileBreakdown.java similarity index 91% rename from core/src/main/java/org/elasticsearch/search/profile/QueryProfileBreakdown.java rename to core/src/main/java/org/elasticsearch/search/profile/query/QueryProfileBreakdown.java index fdb13a49977..d0608eb01af 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/QueryProfileBreakdown.java +++ b/core/src/main/java/org/elasticsearch/search/profile/query/QueryProfileBreakdown.java @@ -17,7 +17,9 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; + +import org.elasticsearch.search.profile.AbstractProfileBreakdown; /** * A record of timings for the various operations that may happen during query execution. diff --git a/core/src/main/java/org/elasticsearch/search/profile/QueryProfiler.java b/core/src/main/java/org/elasticsearch/search/profile/query/QueryProfiler.java similarity index 97% rename from core/src/main/java/org/elasticsearch/search/profile/QueryProfiler.java rename to core/src/main/java/org/elasticsearch/search/profile/query/QueryProfiler.java index f8fcf5fbf13..57341ee132f 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/QueryProfiler.java +++ b/core/src/main/java/org/elasticsearch/search/profile/query/QueryProfiler.java @@ -17,9 +17,10 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; import org.apache.lucene.search.Query; +import org.elasticsearch.search.profile.ProfileResult; import java.util.List; import java.util.Objects; diff --git a/core/src/main/java/org/elasticsearch/search/profile/QueryTimingType.java b/core/src/main/java/org/elasticsearch/search/profile/query/QueryTimingType.java similarity index 95% rename from core/src/main/java/org/elasticsearch/search/profile/QueryTimingType.java rename to core/src/main/java/org/elasticsearch/search/profile/query/QueryTimingType.java index 5fb3b29dee3..5f194a7d5f1 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/QueryTimingType.java +++ b/core/src/main/java/org/elasticsearch/search/profile/query/QueryTimingType.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; import java.util.Locale; diff --git a/core/src/main/java/org/elasticsearch/search/query/QueryPhase.java b/core/src/main/java/org/elasticsearch/search/query/QueryPhase.java index da849828e7a..df68064f617 100644 --- a/core/src/main/java/org/elasticsearch/search/query/QueryPhase.java +++ b/core/src/main/java/org/elasticsearch/search/query/QueryPhase.java @@ -52,10 +52,10 @@ import org.elasticsearch.search.SearchService; import org.elasticsearch.search.aggregations.AggregationPhase; import org.elasticsearch.search.internal.ScrollContext; import org.elasticsearch.search.internal.SearchContext; -import org.elasticsearch.search.profile.CollectorResult; -import org.elasticsearch.search.profile.InternalProfileCollector; import org.elasticsearch.search.profile.ProfileShardResult; import org.elasticsearch.search.profile.SearchProfileShardResults; +import org.elasticsearch.search.profile.query.CollectorResult; +import org.elasticsearch.search.profile.query.InternalProfileCollector; import org.elasticsearch.search.rescore.RescorePhase; import org.elasticsearch.search.rescore.RescoreSearchContext; import org.elasticsearch.search.sort.SortAndFormats; @@ -113,7 +113,7 @@ public class QueryPhase implements SearchPhase { if (searchContext.getProfilers() != null) { List shardResults = SearchProfileShardResults - .buildShardResults(searchContext.getProfilers().getProfilers()); + .buildShardResults(searchContext.getProfilers().getQueryProfilers()); searchContext.queryResult().profileResults(shardResults); } } @@ -365,7 +365,7 @@ public class QueryPhase implements SearchPhase { try { if (collector != null) { if (doProfile) { - searchContext.getProfilers().getCurrent().setCollector((InternalProfileCollector) collector); + searchContext.getProfilers().getCurrentQueryProfiler().setCollector((InternalProfileCollector) collector); } searcher.search(query, collector); } @@ -386,7 +386,7 @@ public class QueryPhase implements SearchPhase { if (searchContext.getProfilers() != null) { List shardResults = SearchProfileShardResults - .buildShardResults(searchContext.getProfilers().getProfilers()); + .buildShardResults(searchContext.getProfilers().getQueryProfilers()); searchContext.queryResult().profileResults(shardResults); } diff --git a/core/src/test/java/org/elasticsearch/search/profile/ProfileTests.java b/core/src/test/java/org/elasticsearch/search/profile/query/ProfileTests.java similarity index 97% rename from core/src/test/java/org/elasticsearch/search/profile/ProfileTests.java rename to core/src/test/java/org/elasticsearch/search/profile/query/ProfileTests.java index ebae8e64f32..7488dbceee7 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/ProfileTests.java +++ b/core/src/test/java/org/elasticsearch/search/profile/query/ProfileTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field.Store; @@ -37,6 +37,9 @@ import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.TestUtil; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.search.internal.ContextIndexSearcher; +import org.elasticsearch.search.profile.ProfileResult; +import org.elasticsearch.search.profile.query.QueryProfiler; +import org.elasticsearch.search.profile.query.QueryTimingType; import org.elasticsearch.test.ESTestCase; import org.junit.AfterClass; import org.junit.BeforeClass; diff --git a/core/src/test/java/org/elasticsearch/search/profile/QueryProfilerIT.java b/core/src/test/java/org/elasticsearch/search/profile/query/QueryProfilerIT.java similarity index 97% rename from core/src/test/java/org/elasticsearch/search/profile/QueryProfilerIT.java rename to core/src/test/java/org/elasticsearch/search/profile/query/QueryProfilerIT.java index d9878774576..371aaadd3a7 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/QueryProfilerIT.java +++ b/core/src/test/java/org/elasticsearch/search/profile/query/QueryProfilerIT.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; import org.apache.lucene.util.English; import org.elasticsearch.action.index.IndexRequestBuilder; @@ -29,6 +29,9 @@ import org.elasticsearch.action.search.ShardSearchFailure; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.profile.ProfileResult; +import org.elasticsearch.search.profile.ProfileShardResult; +import org.elasticsearch.search.profile.query.CollectorResult; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.ESIntegTestCase; @@ -36,7 +39,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import static org.elasticsearch.search.profile.RandomQueryGenerator.randomQueryBuilder; +import static org.elasticsearch.search.profile.query.RandomQueryGenerator.randomQueryBuilder; import static org.elasticsearch.test.hamcrest.DoubleMatcher.nearlyEqual; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; @@ -160,7 +163,8 @@ public class QueryProfilerIT extends ESIntegTestCase { nearlyEqual(vanillaMaxScore, profileMaxScore, 0.001)); } - assertThat("Profile totalHits of [" + profileResponse.getHits().totalHits() + "] is not close to Vanilla totalHits [" + vanillaResponse.getHits().totalHits() + "]", + assertThat("Profile totalHits of [" + profileResponse.getHits().totalHits() + "] is not close to Vanilla totalHits [" + + vanillaResponse.getHits().totalHits() + "]", vanillaResponse.getHits().getTotalHits(), equalTo(profileResponse.getHits().getTotalHits())); SearchHit[] vanillaHits = vanillaResponse.getHits().getHits(); @@ -237,7 +241,8 @@ public class QueryProfilerIT extends ESIntegTestCase { indexRandom(true, docs); - QueryBuilder q = QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("field1", "one")).must(QueryBuilders.matchQuery("field1", "two")); + QueryBuilder q = QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("field1", "one")) + .must(QueryBuilders.matchQuery("field1", "two")); SearchResponse resp = client().prepareSearch() .setQuery(q) @@ -355,7 +360,8 @@ public class QueryProfilerIT extends ESIntegTestCase { refresh(); - QueryBuilder q = QueryBuilders.boolQuery().must(QueryBuilders.boolQuery().must(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("field1", "one")))); + QueryBuilder q = QueryBuilders.boolQuery() + .must(QueryBuilders.boolQuery().must(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("field1", "one")))); logger.info("Query: {}", q); diff --git a/core/src/test/java/org/elasticsearch/search/profile/RandomQueryGenerator.java b/core/src/test/java/org/elasticsearch/search/profile/query/RandomQueryGenerator.java similarity index 99% rename from core/src/test/java/org/elasticsearch/search/profile/RandomQueryGenerator.java rename to core/src/test/java/org/elasticsearch/search/profile/query/RandomQueryGenerator.java index fff0b99c4d1..7fb896e1b2f 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/RandomQueryGenerator.java +++ b/core/src/test/java/org/elasticsearch/search/profile/query/RandomQueryGenerator.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.profile; +package org.elasticsearch.search.profile.query; import org.apache.lucene.util.English; import org.elasticsearch.common.unit.Fuzziness;