Skip to content

Commit

Permalink
Make DfsPhase a utility class (elastic#112553)
Browse files Browse the repository at this point in the history
This thing has no state, no need to have an instance for it.
  • Loading branch information
original-brownbear authored Sep 5, 2024
1 parent b6f8f4c commit c805f90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv

private final BigArrays bigArrays;

private final DfsPhase dfsPhase = new DfsPhase();

private final FetchPhase fetchPhase;
private final RankFeatureShardPhase rankFeatureShardPhase;
private volatile boolean enableSearchWorkerThreads;
Expand Down Expand Up @@ -511,7 +509,7 @@ private DfsSearchResult executeDfsPhase(ShardSearchRequest request, SearchShardT
Releasable ignored = readerContext.markAsUsed(getKeepAlive(request));
SearchContext context = createContext(readerContext, request, task, ResultsType.DFS, false)
) {
dfsPhase.execute(context);
DfsPhase.execute(context);
return context.dfsResult();
} catch (Exception e) {
logger.trace("Dfs phase failed", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
*/
public class DfsPhase {

public void execute(SearchContext context) {
private DfsPhase() {}

public static void execute(SearchContext context) {
try {
collectStatistics(context);
executeKnnVectorQuery(context);
Expand All @@ -65,7 +67,7 @@ public void execute(SearchContext context) {
}
}

private void collectStatistics(SearchContext context) throws IOException {
private static void collectStatistics(SearchContext context) throws IOException {
final DfsProfiler profiler = context.getProfilers() == null ? null : context.getProfilers().getDfsProfiler();

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

0 comments on commit c805f90

Please sign in to comment.