mirror of https://github.com/apache/lucene.git
add a numeric dv field to disk full test and fix diskdv (some codecs still fail)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1436414 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
66dc7bef6b
commit
ba67596a0e
|
@ -37,15 +37,23 @@ class DiskDocValuesConsumer extends DocValuesConsumer {
|
|||
final int maxDoc;
|
||||
|
||||
DiskDocValuesConsumer(SegmentWriteState state) throws IOException {
|
||||
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "ddvd");
|
||||
data = state.directory.createOutput(dataName, state.context);
|
||||
CodecUtil.writeHeader(data, DiskDocValuesFormat.DATA_CODEC,
|
||||
DiskDocValuesFormat.VERSION_CURRENT);
|
||||
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "ddvm");
|
||||
meta = state.directory.createOutput(metaName, state.context);
|
||||
CodecUtil.writeHeader(meta, DiskDocValuesFormat.METADATA_CODEC,
|
||||
DiskDocValuesFormat.VERSION_CURRENT);
|
||||
maxDoc = state.segmentInfo.getDocCount();
|
||||
boolean success = false;
|
||||
try {
|
||||
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "ddvd");
|
||||
data = state.directory.createOutput(dataName, state.context);
|
||||
CodecUtil.writeHeader(data, DiskDocValuesFormat.DATA_CODEC,
|
||||
DiskDocValuesFormat.VERSION_CURRENT);
|
||||
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "ddvm");
|
||||
meta = state.directory.createOutput(metaName, state.context);
|
||||
CodecUtil.writeHeader(meta, DiskDocValuesFormat.METADATA_CODEC,
|
||||
DiskDocValuesFormat.VERSION_CURRENT);
|
||||
maxDoc = state.segmentInfo.getDocCount();
|
||||
success = true;
|
||||
} finally {
|
||||
if (!success) {
|
||||
IOUtils.closeWhileHandlingException(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -146,7 +154,18 @@ class DiskDocValuesConsumer extends DocValuesConsumer {
|
|||
public void close() throws IOException {
|
||||
// nocommit: just write this to a RAMfile or something and flush it here, with #fields first.
|
||||
// this meta is a tiny file so this hurts nobody
|
||||
meta.writeVInt(-1);
|
||||
IOUtils.close(data, meta);
|
||||
boolean success = false;
|
||||
try {
|
||||
if (meta != null) {
|
||||
meta.writeVInt(-1);
|
||||
}
|
||||
success = true;
|
||||
} finally {
|
||||
if (success) {
|
||||
IOUtils.close(data, meta);
|
||||
} else {
|
||||
IOUtils.closeWhileHandlingException(data, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.lucene.codecs.LiveDocsFormat;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.document.LongDocValuesField;
|
||||
import org.apache.lucene.document.TextField;
|
||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -558,6 +559,7 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase {
|
|||
{
|
||||
Document doc = new Document();
|
||||
doc.add(newTextField("content", "aaa", Field.Store.NO));
|
||||
doc.add(new LongDocValuesField("numericdv", 1));
|
||||
writer.addDocument(doc);
|
||||
}
|
||||
|
||||
|
@ -566,6 +568,7 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase {
|
|||
Document doc = new Document();
|
||||
doc.add(newTextField("content", "aaa " + index, Field.Store.NO));
|
||||
doc.add(newTextField("id", "" + index, Field.Store.NO));
|
||||
doc.add(new LongDocValuesField("numericdv", 1));
|
||||
writer.addDocument(doc);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue