lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject svn commit: r1700437 - in /lucene/dev/trunk/lucene: CHANGES.txt core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
Date Tue, 01 Sep 2015 09:23:50 GMT
Author: jpountz
Date: Tue Sep  1 09:23:50 2015
New Revision: 1700437

URL: http://svn.apache.org/r1700437
Log:
LUCENE-6756: MatchAllDocsQuery now has a dedicated BulkScorer.

Modified:
    lucene/dev/trunk/lucene/CHANGES.txt
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1700437&r1=1700436&r2=1700437&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Tue Sep  1 09:23:50 2015
@@ -14,6 +14,7 @@ System Requirements
   all other modules with "compact2".  (Robert Muir, Uwe Schindler)
 
 New Features
+
 * LUCENE-6747: FingerprintFilter is a TokenFilter that outputs a single
   token which is a concatenation of the sorted and de-duplicated set of 
   input tokens. Useful for normalizing short text in clustering/linking 
@@ -76,6 +77,9 @@ Optimizations
 * LUCENE-6720: ValueSourceScorer, returned from
   FunctionValues.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.

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java?rev=1700437&r1=1700436&r2=1700437&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
Tue Sep  1 09:23:50 2015
@@ -40,6 +40,31 @@ public final class MatchAllDocsQuery ext
       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;
+          }
+        };
+      }
     };
   }
 



Mime
View raw message