inline the call to createWeight to even more tightly isolate the regression

This commit is contained in:
Greg Miller 2024-08-16 10:13:43 -07:00
parent 3f2cc333bf
commit c30bb6f3ae
1 changed files with 19 additions and 3 deletions

View File

@ -631,12 +631,28 @@ public class IndexSearcher {
public <C extends Collector, T> T search(Query query, CollectorManager<C, T> collectorManager) public <C extends Collector, T> T search(Query query, CollectorManager<C, T> collectorManager)
throws IOException { throws IOException {
final C firstCollector = collectorManager.newCollector(); final C firstCollector = collectorManager.newCollector();
query = rewrite(query, firstCollector.scoreMode().needsScores()); final ScoreMode scoreMode = firstCollector.scoreMode();
// Initializing `collectors` here (before createWeight) causes regression... query = rewrite(query, scoreMode.needsScores());
////////
// Inlining the createWeight method...
// Initializing `collectors` here (before query.createWeight) causes regression...
final List<C> collectors = new ArrayList<>(8); final List<C> collectors = new ArrayList<>(8);
final Weight weight = createWeight(query, firstCollector.scoreMode(), 1);
Weight weight = query.createWeight(this, scoreMode, 1);
// ... but if we move the initialization here, there is no impact. // ... but if we move the initialization here, there is no impact.
// final List<C> collectors = new ArrayList<>(8); // final List<C> collectors = new ArrayList<>(8);
final QueryCache queryCache = this.queryCache;
if (scoreMode.needsScores() == false && queryCache != null) {
weight = queryCache.doCache(weight, queryCachingPolicy);
}
// ...end inlining of createWeight method
////////
return search(weight, collectorManager, firstCollector, collectors); return search(weight, collectorManager, firstCollector, collectors);
} }