You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2014/02/11 16:37:07 UTC

svn commit: r1567185 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java

Author: shaie
Date: Tue Feb 11 15:37:06 2014
New Revision: 1567185

URL: http://svn.apache.org/r1567185
Log:
LUCENE-5440: add back elasticity assumptions

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java?rev=1567185&r1=1567184&r2=1567185&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java Tue Feb 11 15:37:06 2014
@@ -161,19 +161,21 @@ final class SloppyPhraseScorer extends S
         return false; // exhausted
       }
       if (k != k0) { // careful: mark only those currently in the queue
+        bits = FixedBitSet.ensureCapacity(bits, k);
         bits.set(k); // mark that pp2 need to be re-queued
       }
     }
     // collisions resolved, now re-queue
     // empty (partially) the queue until seeing all pps advanced for resolving collisions
     int n = 0;
-    // TODO can't this be checked once and decremented as we clear bits?
-    // in fact, we don't even need to clear any bits, since the bitset is totally discarded
-    // only need to pop as many set bits from the pq.
+    // TODO would be good if we can avoid calling cardinality() in each iteration!
+    int numBits = bits.length(); // larges bit we set
     while (bits.cardinality() > 0) {
       PhrasePositions pp2 = pq.pop();
       rptStack[n++] = pp2;
-      if (pp2.rptGroup >= 0 && bits.get(pp2.rptInd)) {
+      if (pp2.rptGroup >= 0 
+          && pp2.rptInd < numBits  // this bit may not have been set
+          && bits.get(pp2.rptInd)) {
         bits.clear(pp2.rptInd);
       }
     }