lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r776819 - in /lucene/java/trunk/src: java/org/apache/lucene/index/SegmentReader.java test/org/apache/lucene/index/TestIndexReaderReopen.java
Date Wed, 20 May 2009 19:39:00 GMT
Author: mikemccand
Date: Wed May 20 19:38:59 2009
New Revision: 776819

URL: http://svn.apache.org/viewvc?rev=776819&view=rev
Log:
LUCENE-1645: clone child SegmentReaders on reopening/cloning MultiSegmentReader so changes
remain private

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java?rev=776819&r1=776818&r2=776819&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java Wed May 20 19:38:59
2009
@@ -652,7 +652,8 @@
     }
 
     // if we're cloning we need to run through the reopenSegment logic
-    if (normsUpToDate && deletionsUpToDate && !doClone && openReadOnly
== readOnly) {
+    // also if both old and new readers aren't readonly, we clone to avoid sharing modifications
+    if (normsUpToDate && deletionsUpToDate && !doClone && openReadOnly
&& readOnly) {
       return this;
     }    
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=776819&r1=776818&r2=776819&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java Wed May
20 19:38:59 2009
@@ -1160,21 +1160,20 @@
 
   public void testDeletes() throws Throwable {
     Directory dir = new MockRAMDirectory();
-    createIndex(dir, false);
-    // Get delete bitVector
-    modifyIndex(0, dir);
-    IndexReader r1 = IndexReader.open(dir);
+    createIndex(dir, false); // Create an index with a bunch of docs (1 segment)
 
-    // Add doc:
-    modifyIndex(5, dir);
+    modifyIndex(0, dir); // Get delete bitVector on 1st segment
+    modifyIndex(5, dir); // Add a doc (2 segments)
 
-    IndexReader r2 = r1.reopen();
-    assertTrue(r1 != r2);
+    IndexReader r1 = IndexReader.open(dir); // MSR
 
-    IndexReader[] rs2 = r2.getSequentialSubReaders();
+    modifyIndex(5, dir); // Add another doc (3 segments)
 
-    SegmentReader sr1 = (SegmentReader) r1;
-    SegmentReader sr2 = (SegmentReader) rs2[0];
+    IndexReader r2 = r1.reopen(); // MSR
+    assertTrue(r1 != r2);
+
+    SegmentReader sr1 = (SegmentReader) r1.getSequentialSubReaders()[0]; // Get SRs for the
first segment from original
+    SegmentReader sr2 = (SegmentReader) r2.getSequentialSubReaders()[0]; // and reopened
IRs
 
     // At this point they share the same BitVector
     assertTrue(sr1.deletedDocs==sr2.deletedDocs);



Mime
View raw message