Skip to content

Commit c805f90

Browse files
Make DfsPhase a utility class (elastic#112553)
This thing has no state, no need to have an instance for it.
1 parent b6f8f4c commit c805f90

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

server/src/main/java/org/elasticsearch/search/SearchService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,6 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
278278

279279
private final BigArrays bigArrays;
280280

281-
private final DfsPhase dfsPhase = new DfsPhase();
282-
283281
private final FetchPhase fetchPhase;
284282
private final RankFeatureShardPhase rankFeatureShardPhase;
285283
private volatile boolean enableSearchWorkerThreads;
@@ -511,7 +509,7 @@ private DfsSearchResult executeDfsPhase(ShardSearchRequest request, SearchShardT
511509
Releasable ignored = readerContext.markAsUsed(getKeepAlive(request));
512510
SearchContext context = createContext(readerContext, request, task, ResultsType.DFS, false)
513511
) {
514-
dfsPhase.execute(context);
512+
DfsPhase.execute(context);
515513
return context.dfsResult();
516514
} catch (Exception e) {
517515
logger.trace("Dfs phase failed", e);

server/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
*/
5353
public class DfsPhase {
5454

55-
public void execute(SearchContext context) {
55+
private DfsPhase() {}
56+
57+
public static void execute(SearchContext context) {
5658
try {
5759
collectStatistics(context);
5860
executeKnnVectorQuery(context);
@@ -65,7 +67,7 @@ public void execute(SearchContext context) {
6567
}
6668
}
6769

68-
private void collectStatistics(SearchContext context) throws IOException {
70+
private static void collectStatistics(SearchContext context) throws IOException {
6971
final DfsProfiler profiler = context.getProfilers() == null ? null : context.getProfilers().getDfsProfiler();
7072

7173
Map<String, CollectionStatistics> fieldStatistics = new HashMap<>();

0 commit comments

Comments
 (0)