From 10a4288a4c3135d987a2cdee259f081a45f8467b Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Thu, 10 Nov 2016 17:32:19 +0100 Subject: [PATCH] Remove unused ClusterService dependency from SearchPhaseController (#21421) --- .../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 58b2a7d4aa8..6312d051656 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.SortField; 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 @@ import java.util.stream.StreamSupport; 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 class SearchPhaseController extends AbstractComponent { 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 022519d3d9d..1b818d86eac 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 class TransportSearchAction extends HandledTransportAction 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 b7635d3dc32..df25f0e2635 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 abstract class InternalAggregation implements Aggregation, ToXContent, Na 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 abstract class InternalAggregation implements Aggregation, ToXContent, Na public ScriptService scriptService() { return scriptService; } - - public ClusterState clusterState() { - return clusterState; - } } protected final String name; @@ -126,7 +119,6 @@ public abstract class InternalAggregation implements Aggregation, ToXContent, Na protected abstract void doWriteTo(StreamOutput out) throws IOException; - @Override public String getName() { return name; @@ -215,5 +207,4 @@ public abstract class InternalAggregation implements Aggregation, ToXContent, Na 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 2778a9dbf47..253f0146634 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 @@ package org.elasticsearch.action.search; 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 {