Skip to content

Commit

Permalink
Made QueryCollectorContext methods create, createManager and postProc…
Browse files Browse the repository at this point in the history
…ess public

Signed-off-by: Martin Gaievski <[email protected]>
  • Loading branch information
martin-gaievski committed Jan 10, 2024
1 parent ab0f70e commit 021f593
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Automatically add scheme to discovery.ec2.endpoint ([#11512](https://github.com/opensearch-project/OpenSearch/pull/11512))
- Restore support for Java 8 for RestClient ([#11562](https://github.com/opensearch-project/OpenSearch/pull/11562))
- Add deleted doc count in _cat/shards ([#11678](https://github.com/opensearch-project/OpenSearch/pull/11678))
- Refactor QueryCollectorContext to improve extensibility ([#11778](https://github.com/opensearch-project/OpenSearch/pull/11778))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public ScoreMode scoreMode() {
* Creates a collector that delegates documents to the provided <code>in</code> collector.
* @param in The delegate collector
*/
abstract Collector create(Collector in) throws IOException;
public abstract Collector create(Collector in) throws IOException;

abstract CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException;
public abstract CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException;

/**
* Wraps this collector with a profiler
Expand All @@ -116,7 +116,7 @@ protected InternalProfileCollectorManager createWithProfiler(InternalProfileColl
*
* @param result The query search result to populate
*/
void postProcess(QuerySearchResult result) throws IOException {}
public void postProcess(QuerySearchResult result) throws IOException {}

/**
* Creates the collector tree from the provided <code>collectors</code>
Expand Down Expand Up @@ -149,12 +149,12 @@ static InternalProfileCollector createQueryCollectorWithProfiler(List<QueryColle
static QueryCollectorContext createMinScoreCollectorContext(float minScore) {
return new QueryCollectorContext(REASON_SEARCH_MIN_SCORE) {
@Override
Collector create(Collector in) {
public Collector create(Collector in) {
return new MinimumScoreCollector(in, minScore);
}

@Override
CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException {
public CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException {
return new MinimumCollectorManager(in, minScore);
}
};
Expand All @@ -166,13 +166,13 @@ CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, Re
static QueryCollectorContext createFilteredCollectorContext(IndexSearcher searcher, Query query) {
return new QueryCollectorContext(REASON_SEARCH_POST_FILTER) {
@Override
Collector create(Collector in) throws IOException {
public Collector create(Collector in) throws IOException {
final Weight filterWeight = searcher.createWeight(searcher.rewrite(query), ScoreMode.COMPLETE_NO_SCORES, 1f);
return new FilteredCollector(in, filterWeight);
}

@Override
CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException {
public CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException {
final Weight filterWeight = searcher.createWeight(searcher.rewrite(query), ScoreMode.COMPLETE_NO_SCORES, 1f);
return new FilteredCollectorManager(in, filterWeight);
}
Expand All @@ -187,7 +187,7 @@ static QueryCollectorContext createMultiCollectorContext(
) {
return new QueryCollectorContext(REASON_SEARCH_MULTI) {
@Override
Collector create(Collector in) throws IOException {
public Collector create(Collector in) throws IOException {
List<Collector> subCollectors = new ArrayList<>();
subCollectors.add(in);
for (CollectorManager<? extends Collector, ReduceableSearchResult> manager : subs) {
Expand Down Expand Up @@ -244,7 +244,7 @@ protected InternalProfileCollectorManager createWithProfiler(InternalProfileColl
}

@Override
CollectorManager<? extends Collector, ReduceableSearchResult> createManager(
public CollectorManager<? extends Collector, ReduceableSearchResult> createManager(
CollectorManager<? extends Collector, ReduceableSearchResult> in
) throws IOException {
final List<CollectorManager<?, ReduceableSearchResult>> managers = new ArrayList<>();
Expand All @@ -267,7 +267,7 @@ static QueryCollectorContext createEarlyTerminationCollectorContext(int numHits)
* can terminate the collection independently of the provided <code>in</code> {@link Collector}.
*/
@Override
Collector create(Collector in) {
public Collector create(Collector in) {
assert collector == null;

List<Collector> subCollectors = new ArrayList<>();
Expand All @@ -278,7 +278,7 @@ Collector create(Collector in) {
}

@Override
CollectorManager<? extends Collector, ReduceableSearchResult> createManager(
public CollectorManager<? extends Collector, ReduceableSearchResult> createManager(
CollectorManager<? extends Collector, ReduceableSearchResult> in
) throws IOException {
return new EarlyTerminatingCollectorManager<>(in, numHits, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private EmptyTopDocsCollectorContext(
}

@Override
CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException {
public CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException {
assert in == null;

CollectorManager<?, ReduceableSearchResult> manager = null;
Expand Down Expand Up @@ -205,13 +205,13 @@ CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, Re
}

@Override
Collector create(Collector in) {
public Collector create(Collector in) {
assert in == null;
return collector;
}

@Override
void postProcess(QuerySearchResult result) {
public void postProcess(QuerySearchResult result) {
final TotalHits totalHitCount = hitCountSupplier.get();
final TopDocs topDocs;
if (sort != null) {
Expand Down Expand Up @@ -267,19 +267,19 @@ private CollapsingTopDocsCollectorContext(
}

@Override
Collector create(Collector in) throws IOException {
public Collector create(Collector in) throws IOException {
assert in == null;
return collector;
}

@Override
void postProcess(QuerySearchResult result) throws IOException {
public void postProcess(QuerySearchResult result) throws IOException {
final CollapseTopFieldDocs topDocs = topDocsCollector.getTopDocs();
result.topDocs(new TopDocsAndMaxScore(topDocs, maxScoreSupplier.get()), sortFmt);
}

@Override
CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException {
public CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException {
return new CollectorManager<Collector, ReduceableSearchResult>() {
@Override
public Collector newCollector() throws IOException {
Expand Down Expand Up @@ -543,7 +543,7 @@ public ReduceableSearchResult reduce(Collection<Collector> collectors) throws IO
}

@Override
CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException {
public CollectorManager<?, ReduceableSearchResult> createManager(CollectorManager<?, ReduceableSearchResult> in) throws IOException {
assert in == null;
return new SimpleTopDocsCollectorManager();
}
Expand All @@ -556,7 +556,7 @@ protected ReduceableSearchResult reduceWith(final TopDocs topDocs, final float m
}

@Override
Collector create(Collector in) {
public Collector create(Collector in) {
assert in == null;
return collector;
}
Expand Down Expand Up @@ -619,7 +619,7 @@ TopDocsAndMaxScore newTopDocs() {
}

@Override
void postProcess(QuerySearchResult result) throws IOException {
public void postProcess(QuerySearchResult result) throws IOException {
final TopDocsAndMaxScore topDocs = newTopDocs();
result.topDocs(topDocs, sortAndFormats == null ? null : sortAndFormats.formats);
}
Expand Down Expand Up @@ -684,7 +684,7 @@ protected ReduceableSearchResult reduceWith(final TopDocs topDocs, final float m
}

@Override
void postProcess(QuerySearchResult result) throws IOException {
public void postProcess(QuerySearchResult result) throws IOException {
final TopDocsAndMaxScore topDocs = newTopDocs();
if (scrollContext.totalHits == null) {
// first round
Expand Down

0 comments on commit 021f593

Please sign in to comment.