LUCENE-767: derive maxDoc from SegmentInfo.docCount instead of file length of fieldsReader's index file

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@494871 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2007-01-10 16:06:33 +00:00
parent 59b8e30f85
commit 91204f8d54
3 changed files with 17 additions and 10 deletions

View File

@ -303,6 +303,13 @@ Bug fixes
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

View File

@ -360,7 +360,7 @@ class SegmentReader extends IndexReader {
}
public int maxDoc() {
return fieldsReader.size();
return si.docCount;
}
/**

View File

@ -114,13 +114,13 @@ public class TestDoc extends TestCase {
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 @@ public class TestDoc extends TestCase {
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 @@ public class TestDoc extends TestCase {
}
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);