lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r494871 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/index/SegmentReader.java src/test/org/apache/lucene/index/TestDoc.java
Date Wed, 10 Jan 2007 16:06:34 GMT
Author: mikemccand
Date: Wed Jan 10 08:06:33 2007
New Revision: 494871

URL: http://svn.apache.org/viewvc?view=rev&rev=494871
Log:
LUCENE-767: derive maxDoc from SegmentInfo.docCount instead of file length of fieldsReader's
index file

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?view=diff&rev=494871&r1=494870&r2=494871
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Wed Jan 10 08:06:33 2007
@@ -303,6 +303,13 @@
 31. Remove "tvp" from known index file extensions because it is
     never used. (Nicolas Lalevée via Bernhard Messer)
     
+32. LUCENE-767: Change how SegmentReader.maxDoc() is computed to not
+    rely on file length check and instead use the SegmentInfo's
+    docCount that's already stored explicitly in the index.  This is a
+    defensive bug fix (ie, there is no known problem seen "in real
+    life" due to this, just a possible future problem).  (Chuck
+    Williams via Mike McCandless)
+
 Optimizations
 
   1. LUCENE-586: TermDocs.skipTo() is now more efficient for

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?view=diff&rev=494871&r1=494870&r2=494871
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java Wed Jan 10 08:06:33
2007
@@ -360,7 +360,7 @@
   }
 
   public int maxDoc() {
-    return fieldsReader.size();
+    return si.docCount;
   }
 
   /**

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java?view=diff&rev=494871&r1=494870&r2=494871
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestDoc.java Wed Jan 10 08:06:33 2007
@@ -114,13 +114,13 @@
       indexDoc("two", "test2.txt");
       printSegment(out, "two");
 
-      merge("one", "two", "merge", false);
+      merge("one", 1, "two", 1, "merge", false);
       printSegment(out, "merge");
 
-      merge("one", "two", "merge2", false);
+      merge("one", 1, "two", 1, "merge2", false);
       printSegment(out, "merge2");
 
-      merge("merge", "merge2", "merge3", false);
+      merge("merge", 2, "merge2", 2, "merge3", false);
       printSegment(out, "merge3");
 
       out.close();
@@ -140,13 +140,13 @@
       indexDoc("two", "test2.txt");
       printSegment(out, "two");
 
-      merge("one", "two", "merge", true);
+      merge("one", 1, "two", 1, "merge", true);
       printSegment(out, "merge");
 
-      merge("one", "two", "merge2", true);
+      merge("one", 1, "two", 1, "merge2", true);
       printSegment(out, "merge2");
 
-      merge("merge", "merge2", "merge3", true);
+      merge("merge", 2, "merge2", 2, "merge3", true);
       printSegment(out, "merge3");
 
       out.close();
@@ -174,12 +174,12 @@
    }
 
 
-   private void merge(String seg1, String seg2, String merged, boolean useCompoundFile)
+   private void merge(String seg1, int docCount1, String seg2, int docCount2, String merged,
boolean useCompoundFile)
    throws Exception {
       Directory directory = FSDirectory.getDirectory(indexDir, false);
 
-      SegmentReader r1 = SegmentReader.get(new SegmentInfo(seg1, 1, directory));
-      SegmentReader r2 = SegmentReader.get(new SegmentInfo(seg2, 1, directory));
+      SegmentReader r1 = SegmentReader.get(new SegmentInfo(seg1, docCount1, directory));
+      SegmentReader r2 = SegmentReader.get(new SegmentInfo(seg2, docCount2, directory));
 
       SegmentMerger merger =
         new SegmentMerger(directory, merged);



Mime
View raw message