LUCENE-6019: add more safety during DV flush

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1633830 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-10-23 15:03:26 +00:00
parent 748fd311e6
commit ad9fb9a9dd
1 changed files with 17 additions and 0 deletions

View File

@ -130,6 +130,10 @@ final class DefaultIndexingChain extends DocConsumer {
PerField perField = fieldHash[i];
while (perField != null) {
if (perField.docValuesWriter != null) {
if (perField.fieldInfo.hasDocValues() == false) {
// BUG
throw new AssertionError("segment=" + state.segmentInfo + ": field=\"" + perField.fieldInfo.name + "\" has no docValues but wrote them");
}
if (dvConsumer == null) {
// lazy init
DocValuesFormat fmt = state.segmentInfo.getCodec().docValuesFormat();
@ -139,6 +143,9 @@ final class DefaultIndexingChain extends DocConsumer {
perField.docValuesWriter.finish(docCount);
perField.docValuesWriter.flush(state, dvConsumer);
perField.docValuesWriter = null;
} else if (perField.fieldInfo.hasDocValues()) {
// BUG
throw new AssertionError("segment=" + state.segmentInfo + ": field=\"" + perField.fieldInfo.name + "\" has docValues but did not write them");
}
perField = perField.next;
}
@ -156,6 +163,16 @@ final class DefaultIndexingChain extends DocConsumer {
IOUtils.closeWhileHandlingException(dvConsumer);
}
}
if (state.fieldInfos.hasDocValues() == false) {
if (dvConsumer != null) {
// BUG
throw new AssertionError("segment=" + state.segmentInfo + ": fieldInfos has no docValues but wrote them");
}
} else if (dvConsumer == null) {
// BUG
throw new AssertionError("segment=" + state.segmentInfo + ": fieldInfos has docValues but did not wrote them");
}
}
/** Catch up for all docs before us that had no stored