From c23348c922a15aba67420f155f5d1638cac6fda9 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 9 Nov 2016 10:34:42 +0100 Subject: [PATCH] Remove unused ClusterService dependency from SearchPhaseController --- .../action/search/SearchPhaseController.java | 12 ++++-------- .../action/search/TransportSearchAction.java | 2 +- .../action/search/TransportSearchScrollAction.java | 3 +-- .../search/aggregations/InternalAggregation.java | 11 +---------- .../action/search/SearchPhaseControllerTests.java | 3 +-- 5 files changed, 8 insertions(+), 23 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java b/core/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java index 58b2a7d4aa863..6312d0516564a 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java @@ -30,10 +30,8 @@ import org.apache.lucene.search.TermStatistics; import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.TopFieldDocs; -import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.collect.HppcMaps; import org.elasticsearch.common.component.AbstractComponent; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.BigArrays; @@ -72,7 +70,7 @@ public class SearchPhaseController extends AbstractComponent { - public static final Comparator> QUERY_RESULT_ORDERING = (o1, o2) -> { + private static final Comparator> QUERY_RESULT_ORDERING = (o1, o2) -> { int i = o1.value.shardTarget().index().compareTo(o2.value.shardTarget().index()); if (i == 0) { i = o1.value.shardTarget().shardId().id() - o2.value.shardTarget().shardId().id(); @@ -80,17 +78,15 @@ public class SearchPhaseController extends AbstractComponent { return i; }; - public static final ScoreDoc[] EMPTY_DOCS = new ScoreDoc[0]; + private static final ScoreDoc[] EMPTY_DOCS = new ScoreDoc[0]; private final BigArrays bigArrays; private final ScriptService scriptService; - private final ClusterService clusterService; - SearchPhaseController(Settings settings, BigArrays bigArrays, ScriptService scriptService, ClusterService clusterService) { + SearchPhaseController(Settings settings, BigArrays bigArrays, ScriptService scriptService) { super(settings); this.bigArrays = bigArrays; this.scriptService = scriptService; - this.clusterService = clusterService; } public AggregatedDfs aggregateDfs(AtomicArray results) { @@ -486,7 +482,7 @@ public InternalSearchResponse merge(boolean ignoreFrom, ScoreDoc[] sortedDocs, for (AtomicArray.Entry entry : queryResults) { aggregationsList.add((InternalAggregations) entry.value.queryResult().aggregations()); } - ReduceContext reduceContext = new ReduceContext(bigArrays, scriptService, clusterService.state()); + ReduceContext reduceContext = new ReduceContext(bigArrays, scriptService); aggregations = InternalAggregations.reduce(aggregationsList, reduceContext); List pipelineAggregators = firstResult.pipelineAggregators(); if (pipelineAggregators != null) { diff --git a/core/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java b/core/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java index 022519d3d9dd4..1b818d86eacf0 100644 --- a/core/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java +++ b/core/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java @@ -69,7 +69,7 @@ public TransportSearchAction(Settings settings, ThreadPool threadPool, BigArrays ClusterService clusterService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { super(settings, SearchAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, SearchRequest::new); - this.searchPhaseController = new SearchPhaseController(settings, bigArrays, scriptService, clusterService);; + this.searchPhaseController = new SearchPhaseController(settings, bigArrays, scriptService); this.searchTransportService = new SearchTransportService(settings, transportService); SearchTransportService.registerRequestHandler(transportService, searchService); this.clusterService = clusterService; diff --git a/core/src/main/java/org/elasticsearch/action/search/TransportSearchScrollAction.java b/core/src/main/java/org/elasticsearch/action/search/TransportSearchScrollAction.java index 219c856617a49..9b70727485ae1 100644 --- a/core/src/main/java/org/elasticsearch/action/search/TransportSearchScrollAction.java +++ b/core/src/main/java/org/elasticsearch/action/search/TransportSearchScrollAction.java @@ -50,10 +50,9 @@ public TransportSearchScrollAction(Settings settings, BigArrays bigArrays, Threa SearchScrollRequest::new); this.clusterService = clusterService; this.searchTransportService = new SearchTransportService(settings, transportService); - this.searchPhaseController = new SearchPhaseController(settings, bigArrays, scriptService, clusterService); + this.searchPhaseController = new SearchPhaseController(settings, bigArrays, scriptService); } - @Override protected final void doExecute(SearchScrollRequest request, ActionListener listener) { throw new UnsupportedOperationException("the task parameter is required"); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java b/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java index b7635d3dc320e..df25f0e263551 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.search.aggregations; -import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.NamedWriteable; import org.elasticsearch.common.io.stream.StreamInput; @@ -69,12 +68,10 @@ public static class ReduceContext { private final BigArrays bigArrays; private final ScriptService scriptService; - private final ClusterState clusterState; - public ReduceContext(BigArrays bigArrays, ScriptService scriptService, ClusterState clusterState) { + public ReduceContext(BigArrays bigArrays, ScriptService scriptService) { this.bigArrays = bigArrays; this.scriptService = scriptService; - this.clusterState = clusterState; } public BigArrays bigArrays() { @@ -84,10 +81,6 @@ public BigArrays bigArrays() { public ScriptService scriptService() { return scriptService; } - - public ClusterState clusterState() { - return clusterState; - } } protected final String name; @@ -126,7 +119,6 @@ public final void writeTo(StreamOutput out) throws IOException { protected abstract void doWriteTo(StreamOutput out) throws IOException; - @Override public String getName() { return name; @@ -215,5 +207,4 @@ public static final class CommonFields extends ParseField.CommonFields { public static final String TO = "to"; public static final String TO_AS_STRING = "to_as_string"; } - } diff --git a/core/src/test/java/org/elasticsearch/action/search/SearchPhaseControllerTests.java b/core/src/test/java/org/elasticsearch/action/search/SearchPhaseControllerTests.java index 2778a9dbf4731..253f014663412 100644 --- a/core/src/test/java/org/elasticsearch/action/search/SearchPhaseControllerTests.java +++ b/core/src/test/java/org/elasticsearch/action/search/SearchPhaseControllerTests.java @@ -21,7 +21,6 @@ import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TopDocs; -import org.elasticsearch.action.search.SearchPhaseController; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.text.Text; import org.elasticsearch.common.util.BigArrays; @@ -57,7 +56,7 @@ public class SearchPhaseControllerTests extends ESTestCase { @Before public void setup() { - searchPhaseController = new SearchPhaseController(Settings.EMPTY, BigArrays.NON_RECYCLING_INSTANCE, null, null); + searchPhaseController = new SearchPhaseController(Settings.EMPTY, BigArrays.NON_RECYCLING_INSTANCE, null); } public void testSort() throws Exception {