Apache Solr open-source search software
LUCENE-6756: MatchAllDocsQuery now has a dedicated BulkScorer.
Adrien Grand1017a685b2d9
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 86377c3acf9..245429afb40 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -14,6 +14,7 @@ System Requirementsall other modules with "compact2". (Robert Muir, Uwe Schindler)New Features+* LUCENE-6747: FingerprintFilter is a TokenFilter that outputs a singletoken which is a concatenation of the sorted and de-duplicated set ofinput tokens. Useful for normalizing short text in clustering/linking@@ -76,6 +77,9 @@ Optimizations* LUCENE-6720: ValueSourceScorer, returned fromFunctionValues.getRangeScorer(), now uses TwoPhaseIterator. (David Smiley)+* LUCENE-6756: MatchAllDocsQuery now has a dedicated BulkScorer for better+ performance when used as a top-level query. (Adrien Grand)+Bug Fixes* LUCENE-6730: Hyper-parameter c is ignored in term frequency NormalizationH1.diff --git a/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java b/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.javaindex 418002dd052..d528b36b1b2 100644--- a/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java+++ b/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java@@ -40,6 +40,31 @@ public final class MatchAllDocsQuery extends Query {public String toString() {return "weight(" + MatchAllDocsQuery.this + ")";}+ @Override+ public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {+ final float score = score();+ final int maxDoc = context.reader().maxDoc();+ return new BulkScorer() {+ @Override+ public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException {+ max = Math.min(max, maxDoc);+ FakeScorer scorer = new FakeScorer();+ scorer.score = score;+ collector.setScorer(scorer);+ for (int doc = min; doc < max; ++doc) {+ scorer.doc = doc;+ if (acceptDocs == null || acceptDocs.get(doc)) {+ collector.collect(doc);+ }+ }+ return max == maxDoc ? DocIdSetIterator.NO_MORE_DOCS : max;+ }+ @Override+ public long cost() {+ return maxDoc;+ }+ };+ }};}