lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r220228 - /lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer2.java
Date Fri, 22 Jul 2005 01:48:36 GMT
Author: ehatcher
Date: Thu Jul 21 18:48:32 2005
New Revision: 220228

URL: http://svn.apache.org/viewcvs?rev=220228&view=rev
Log:
#35823 - Paul Elschots fix for BooleanScorer2 causing ArrayIndexOutOfBoundsException

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer2.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer2.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer2.java?rev=220228&r1=220227&r2=220228&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer2.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer2.java Thu Jul 21 18:48:32
2005
@@ -99,12 +99,17 @@
   /** Count a scorer as a single match. */
   private class SingleMatchScorer extends Scorer {
     private Scorer scorer;
+    private int lastScoredDoc = -1;
+
     SingleMatchScorer(Scorer scorer) {
       super(scorer.getSimilarity());
       this.scorer = scorer;
     }
     public float score() throws IOException {
-      coordinator.nrMatchers++;
+      if (doc() > lastScoredDoc) {
+        lastScoredDoc = doc();
+        coordinator.nrMatchers++;
+      }
       return scorer.score();
     }
     public int doc() {
@@ -125,8 +130,12 @@
   // each scorer from the list counted as a single matcher
   {
     return new DisjunctionSumScorer(scorers) {
+      private int lastScoredDoc = -1;
       public float score() throws IOException {
-        coordinator.nrMatchers += nrMatchers;
+        if (doc() > lastScoredDoc) {
+          lastScoredDoc = doc();
+          coordinator.nrMatchers += super.nrMatchers;
+        }
         return super.score();
       }
     };
@@ -139,8 +148,13 @@
   {
     final int requiredNrMatchers = requiredScorers.size();
     ConjunctionScorer cs = new ConjunctionScorer(defaultSimilarity) {
+      private int lastScoredDoc = -1;
+
       public float score() throws IOException {
-        coordinator.nrMatchers += requiredNrMatchers;
+        if (doc() > lastScoredDoc) {
+          lastScoredDoc = doc();
+          coordinator.nrMatchers += requiredNrMatchers;
+        }
         // All scorers match, so defaultSimilarity super.score() always has 1 as
         // the coordination factor.
         // Therefore the sum of the scores of the requiredScorers



Mime
View raw message