LUCENE-1010: fix corruption case, hit during merge, case when docs with and without term-vectors are mixed

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@580643 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2007-09-29 21:11:57 +00:00
parent 16342bedb9
commit 8315089cdd
3 changed files with 38 additions and 1 deletions

View File

@ -113,6 +113,12 @@ Bug fixes
16. LUCENE-1006: Fixed QueryParser to accept a "" field value (zero 16. LUCENE-1006: Fixed QueryParser to accept a "" field value (zero
length quoted string.) (yonik) length quoted string.) (yonik)
17. LUCENE-1010: Fixed corruption case when document with no term
vector fields is added after documents with term vector fields.
This case is hit during merge and would cause an EOFException.
This bug was introduced with LUCENE-984. (Andi Vajda via Mike
McCandless)
New features New features
1. LUCENE-906: Elision filter for French. 1. LUCENE-906: Elision filter for French.

View File

@ -155,7 +155,8 @@ final class TermVectorsWriter {
tvd.writeVLong(fieldPointer-lastFieldPointer); tvd.writeVLong(fieldPointer-lastFieldPointer);
lastFieldPointer = fieldPointer; lastFieldPointer = fieldPointer;
} }
} } else
tvd.writeVInt(0);
} }
/** Close all streams. */ /** Close all streams. */

View File

@ -1489,4 +1489,34 @@ public class TestIndexWriter extends TestCase
iw.close(); iw.close();
dir.close(); dir.close();
} }
// LUCENE-1010
public void testNoTermVectorAfterTermVectorMerge() throws IOException {
MockRAMDirectory dir = new MockRAMDirectory();
IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(), true);
Document document = new Document();
document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.TOKENIZED,
Field.TermVector.YES));
iw.addDocument(document);
iw.flush();
document = new Document();
document.add(new Field("tvtest", "x y z", Field.Store.NO, Field.Index.TOKENIZED,
Field.TermVector.NO));
iw.addDocument(document);
// Make first segment
iw.flush();
iw.optimize();
document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.TOKENIZED,
Field.TermVector.YES));
iw.addDocument(document);
// Make 2nd segment
iw.flush();
iw.optimize();
iw.close();
dir.close();
}
} }