Skip to content

Commit

Permalink
Assume scode mode from collector
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Gaievski <[email protected]>
  • Loading branch information
martin-gaievski committed Nov 18, 2024
1 parent 65bcf14 commit fd75a58
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public ScoreMode scoreMode() {

private static final ReduceableSearchResult EMPTY_RESULT = result -> {};

private static QueryCollectorContext createEmptyContext(String name, Collector collector) {
private static QueryCollectorContext createEmptyContext(Collector collector) {
String name = String.format(Locale.ROOT, "empty_with_score_mode_%s", collector.scoreMode().toString().toLowerCase(Locale.ROOT));
return new QueryCollectorContext(name) {
@Override
Collector create(Collector in) {
Expand All @@ -108,19 +109,11 @@ public ReduceableSearchResult reduce(Collection<Collector> collectors) {
};
}

private static String formatContextName(ScoreMode scoreMode) {
return String.format(Locale.ROOT, "empty_with_score_mode_%s", scoreMode.toString().toLowerCase(Locale.ROOT));
}

private static final Collector EMPTY_COLLECTOR = createEmptyCollector(ScoreMode.COMPLETE_NO_SCORES);
public static final QueryCollectorContext EMPTY_CONTEXT = createEmptyContext(
formatContextName(ScoreMode.COMPLETE_NO_SCORES),
createEmptyCollector(ScoreMode.COMPLETE_NO_SCORES)
);
public static final QueryCollectorContext EMPTY_CONTEXT_TOP_SCORES_SCORE_MODE = createEmptyContext(
formatContextName(ScoreMode.TOP_SCORES),
createEmptyCollector(ScoreMode.TOP_SCORES)
);
private static final Collector EMPTY_COLLECTOR_TOP_SCORES = createEmptyCollector(ScoreMode.TOP_SCORES);

public static final QueryCollectorContext EMPTY_CONTEXT = createEmptyContext(EMPTY_COLLECTOR);
public static final QueryCollectorContext EMPTY_CONTEXT_TOP_SCORES_SCORE_MODE = createEmptyContext(EMPTY_COLLECTOR_TOP_SCORES);

private String profilerName;

Expand Down

0 comments on commit fd75a58

Please sign in to comment.