Skip to content

Commit 10a4288

Browse files
authored
Remove unused ClusterService dependency from SearchPhaseController (#21421)
1 parent 06aabd9 commit 10a4288

File tree

5 files changed

+8
-23
lines changed

5 files changed

+8
-23
lines changed

core/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@
3030
import org.apache.lucene.search.TermStatistics;
3131
import org.apache.lucene.search.TopDocs;
3232
import org.apache.lucene.search.TopFieldDocs;
33-
import org.elasticsearch.cluster.service.ClusterService;
3433
import org.elasticsearch.common.collect.HppcMaps;
3534
import org.elasticsearch.common.component.AbstractComponent;
36-
import org.elasticsearch.common.inject.Inject;
3735
import org.elasticsearch.common.lucene.Lucene;
3836
import org.elasticsearch.common.settings.Settings;
3937
import org.elasticsearch.common.util.BigArrays;
@@ -72,25 +70,23 @@
7270

7371
public class SearchPhaseController extends AbstractComponent {
7472

75-
public static final Comparator<AtomicArray.Entry<? extends QuerySearchResultProvider>> QUERY_RESULT_ORDERING = (o1, o2) -> {
73+
private static final Comparator<AtomicArray.Entry<? extends QuerySearchResultProvider>> QUERY_RESULT_ORDERING = (o1, o2) -> {
7674
int i = o1.value.shardTarget().index().compareTo(o2.value.shardTarget().index());
7775
if (i == 0) {
7876
i = o1.value.shardTarget().shardId().id() - o2.value.shardTarget().shardId().id();
7977
}
8078
return i;
8179
};
8280

83-
public static final ScoreDoc[] EMPTY_DOCS = new ScoreDoc[0];
81+
private static final ScoreDoc[] EMPTY_DOCS = new ScoreDoc[0];
8482

8583
private final BigArrays bigArrays;
8684
private final ScriptService scriptService;
87-
private final ClusterService clusterService;
8885

89-
SearchPhaseController(Settings settings, BigArrays bigArrays, ScriptService scriptService, ClusterService clusterService) {
86+
SearchPhaseController(Settings settings, BigArrays bigArrays, ScriptService scriptService) {
9087
super(settings);
9188
this.bigArrays = bigArrays;
9289
this.scriptService = scriptService;
93-
this.clusterService = clusterService;
9490
}
9591

9692
public AggregatedDfs aggregateDfs(AtomicArray<DfsSearchResult> results) {
@@ -486,7 +482,7 @@ public InternalSearchResponse merge(boolean ignoreFrom, ScoreDoc[] sortedDocs,
486482
for (AtomicArray.Entry<? extends QuerySearchResultProvider> entry : queryResults) {
487483
aggregationsList.add((InternalAggregations) entry.value.queryResult().aggregations());
488484
}
489-
ReduceContext reduceContext = new ReduceContext(bigArrays, scriptService, clusterService.state());
485+
ReduceContext reduceContext = new ReduceContext(bigArrays, scriptService);
490486
aggregations = InternalAggregations.reduce(aggregationsList, reduceContext);
491487
List<SiblingPipelineAggregator> pipelineAggregators = firstResult.pipelineAggregators();
492488
if (pipelineAggregators != null) {

core/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public TransportSearchAction(Settings settings, ThreadPool threadPool, BigArrays
6969
ClusterService clusterService, ActionFilters actionFilters, IndexNameExpressionResolver
7070
indexNameExpressionResolver) {
7171
super(settings, SearchAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, SearchRequest::new);
72-
this.searchPhaseController = new SearchPhaseController(settings, bigArrays, scriptService, clusterService);;
72+
this.searchPhaseController = new SearchPhaseController(settings, bigArrays, scriptService);
7373
this.searchTransportService = new SearchTransportService(settings, transportService);
7474
SearchTransportService.registerRequestHandler(transportService, searchService);
7575
this.clusterService = clusterService;

core/src/main/java/org/elasticsearch/action/search/TransportSearchScrollAction.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ public TransportSearchScrollAction(Settings settings, BigArrays bigArrays, Threa
5050
SearchScrollRequest::new);
5151
this.clusterService = clusterService;
5252
this.searchTransportService = new SearchTransportService(settings, transportService);
53-
this.searchPhaseController = new SearchPhaseController(settings, bigArrays, scriptService, clusterService);
53+
this.searchPhaseController = new SearchPhaseController(settings, bigArrays, scriptService);
5454
}
5555

56-
5756
@Override
5857
protected final void doExecute(SearchScrollRequest request, ActionListener<SearchResponse> listener) {
5958
throw new UnsupportedOperationException("the task parameter is required");

core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.elasticsearch.search.aggregations;
2020

21-
import org.elasticsearch.cluster.ClusterState;
2221
import org.elasticsearch.common.ParseField;
2322
import org.elasticsearch.common.io.stream.NamedWriteable;
2423
import org.elasticsearch.common.io.stream.StreamInput;
@@ -69,12 +68,10 @@ public static class ReduceContext {
6968

7069
private final BigArrays bigArrays;
7170
private final ScriptService scriptService;
72-
private final ClusterState clusterState;
7371

74-
public ReduceContext(BigArrays bigArrays, ScriptService scriptService, ClusterState clusterState) {
72+
public ReduceContext(BigArrays bigArrays, ScriptService scriptService) {
7573
this.bigArrays = bigArrays;
7674
this.scriptService = scriptService;
77-
this.clusterState = clusterState;
7875
}
7976

8077
public BigArrays bigArrays() {
@@ -84,10 +81,6 @@ public BigArrays bigArrays() {
8481
public ScriptService scriptService() {
8582
return scriptService;
8683
}
87-
88-
public ClusterState clusterState() {
89-
return clusterState;
90-
}
9184
}
9285

9386
protected final String name;
@@ -126,7 +119,6 @@ public final void writeTo(StreamOutput out) throws IOException {
126119

127120
protected abstract void doWriteTo(StreamOutput out) throws IOException;
128121

129-
130122
@Override
131123
public String getName() {
132124
return name;
@@ -215,5 +207,4 @@ public static final class CommonFields extends ParseField.CommonFields {
215207
public static final String TO = "to";
216208
public static final String TO_AS_STRING = "to_as_string";
217209
}
218-
219210
}

core/src/test/java/org/elasticsearch/action/search/SearchPhaseControllerTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.apache.lucene.search.ScoreDoc;
2323
import org.apache.lucene.search.TopDocs;
24-
import org.elasticsearch.action.search.SearchPhaseController;
2524
import org.elasticsearch.common.settings.Settings;
2625
import org.elasticsearch.common.text.Text;
2726
import org.elasticsearch.common.util.BigArrays;
@@ -57,7 +56,7 @@ public class SearchPhaseControllerTests extends ESTestCase {
5756

5857
@Before
5958
public void setup() {
60-
searchPhaseController = new SearchPhaseController(Settings.EMPTY, BigArrays.NON_RECYCLING_INSTANCE, null, null);
59+
searchPhaseController = new SearchPhaseController(Settings.EMPTY, BigArrays.NON_RECYCLING_INSTANCE, null);
6160
}
6261

6362
public void testSort() throws Exception {

0 commit comments

Comments
 (0)