lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r1351130 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/index/CompositeReaderContext.java lucene/core/src/java/org/apache/lucene/util/ReaderUtil.java
Date Sun, 17 Jun 2012 17:24:01 GMT
Author: uschindler
Date: Sun Jun 17 17:24:01 2012
New Revision: 1351130

URL: http://svn.apache.org/viewvc?rev=1351130&view=rev
Log:
Merged revision(s) 1351129 from lucene/dev/trunk:
The base calculation in ReaderUtil.Gather is so complicated, add some assert to verify that
it is still correct. The code lead to another bug I fixed in CompositeReaderContext long time
ago (at least it explains why Simon did it wrong...)

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/index/CompositeReaderContext.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/ReaderUtil.java

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/CompositeReaderContext.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/CompositeReaderContext.java?rev=1351130&r1=1351129&r2=1351130&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/CompositeReaderContext.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/CompositeReaderContext.java
Sun Jun 17 17:24:01 2012
@@ -111,6 +111,7 @@ public final class CompositeReaderContex
           children[i] = build(newParent, sequentialSubReaders[i], i, newDocBase);
           newDocBase += sequentialSubReaders[i].maxDoc();
         }
+        assert newDocBase == cr.maxDoc();
         return newParent;
       }
     }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/ReaderUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/ReaderUtil.java?rev=1351130&r1=1351129&r2=1351130&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/ReaderUtil.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/ReaderUtil.java
Sun Jun 17 17:24:01 2012
@@ -101,20 +101,21 @@ public final class ReaderUtil {
       return run(docBase, topReader);
     }
 
-    private int run(int base, IndexReader reader) throws IOException {
+    private int run(final int base, final IndexReader reader) throws IOException {
       if (reader instanceof AtomicReader) {
         // atomic reader
         add(base, (AtomicReader) reader);
-        base += reader.maxDoc();
+        return base + reader.maxDoc();
       } else {
         assert reader instanceof CompositeReader : "must be a composite reader";
+        int newBase = base;
         IndexReader[] subReaders = ((CompositeReader) reader).getSequentialSubReaders();
         for (int i = 0; i < subReaders.length; i++) {
-          base = run(base, subReaders[i]);
+          newBase = run(newBase, subReaders[i]);
         }
+        assert newBase == base + reader.maxDoc();
+        return newBase;
       }
-
-      return base;
     }
 
     protected abstract void add(int base, AtomicReader r) throws IOException;



Mime
View raw message