mirror of https://github.com/apache/lucene.git
LUCENE-843: SegmentInfo.clone() failed to copy some fields; in certain cases _x.nrm might not be created even when fieldInfos says it has norms
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@553298 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
50787ab505
commit
3e1a31748e
|
@ -338,7 +338,6 @@ final class DocumentsWriter {
|
|||
postingsIsFull = false;
|
||||
flushPending = false;
|
||||
segment = null;
|
||||
hasNorms = false;
|
||||
numDocsInRAM = 0;
|
||||
nextDocID = 0;
|
||||
nextWriteDocID = 0;
|
||||
|
@ -1803,7 +1802,6 @@ final class DocumentsWriter {
|
|||
|
||||
if (hasNorms) {
|
||||
writeNorms(segmentName, numDocsInRAM);
|
||||
hasNorms = false;
|
||||
flushedFiles.add(segmentFileName(IndexFileNames.NORMS_EXTENSION));
|
||||
}
|
||||
|
||||
|
|
|
@ -248,6 +248,9 @@ final class SegmentInfo {
|
|||
if (normGen != null) {
|
||||
si.normGen = (long[]) normGen.clone();
|
||||
}
|
||||
si.docStoreOffset = docStoreOffset;
|
||||
si.docStoreSegment = docStoreSegment;
|
||||
si.docStoreIsCompoundFile = docStoreIsCompoundFile;
|
||||
return si;
|
||||
}
|
||||
|
||||
|
|
|
@ -1293,6 +1293,21 @@ public class TestIndexWriter extends TestCase
|
|||
dir.close();
|
||||
}
|
||||
|
||||
// Make sure we can flush segment w/ norms, then add
|
||||
// empty doc (no norms) and flush
|
||||
public void testEmptyDocAfterFlushingRealDoc() throws IOException {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
|
||||
writer.addDocument(doc);
|
||||
writer.flush();
|
||||
writer.addDocument(new Document());
|
||||
writer.close();
|
||||
IndexReader reader = IndexReader.open(dir);
|
||||
assertEquals(2, reader.numDocs());
|
||||
}
|
||||
|
||||
private void rmDir(File dir) {
|
||||
File[] files = dir.listFiles();
|
||||
if (files != null) {
|
||||
|
|
Loading…
Reference in New Issue