remove bogus null check

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1445014 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-02-12 01:56:10 +00:00
parent 99d5012dd8
commit cebc72fbda
1 changed files with 62 additions and 67 deletions

View File

@ -161,85 +161,80 @@ final class SegmentMerger {
}
private void mergeDocValues(SegmentWriteState segmentWriteState) throws IOException {
if (codec.docValuesFormat() != null) {
DocValuesConsumer consumer = codec.docValuesFormat().fieldsConsumer(segmentWriteState);
boolean success = false;
try {
for (FieldInfo field : mergeState.fieldInfos) {
DocValuesType type = field.getDocValuesType();
if (type != null) {
if (type == DocValuesType.NUMERIC) {
List<NumericDocValues> toMerge = new ArrayList<NumericDocValues>();
for (AtomicReader reader : mergeState.readers) {
NumericDocValues values = reader.getNumericDocValues(field.name);
if (values == null) {
values = NumericDocValues.EMPTY;
}
toMerge.add(values);
DocValuesConsumer consumer = codec.docValuesFormat().fieldsConsumer(segmentWriteState);
boolean success = false;
try {
for (FieldInfo field : mergeState.fieldInfos) {
DocValuesType type = field.getDocValuesType();
if (type != null) {
if (type == DocValuesType.NUMERIC) {
List<NumericDocValues> toMerge = new ArrayList<NumericDocValues>();
for (AtomicReader reader : mergeState.readers) {
NumericDocValues values = reader.getNumericDocValues(field.name);
if (values == null) {
values = NumericDocValues.EMPTY;
}
consumer.mergeNumericField(field, mergeState, toMerge);
} else if (type == DocValuesType.BINARY) {
List<BinaryDocValues> toMerge = new ArrayList<BinaryDocValues>();
for (AtomicReader reader : mergeState.readers) {
BinaryDocValues values = reader.getBinaryDocValues(field.name);
if (values == null) {
values = BinaryDocValues.EMPTY;
}
toMerge.add(values);
}
consumer.mergeBinaryField(field, mergeState, toMerge);
} else if (type == DocValuesType.SORTED) {
List<SortedDocValues> toMerge = new ArrayList<SortedDocValues>();
for (AtomicReader reader : mergeState.readers) {
SortedDocValues values = reader.getSortedDocValues(field.name);
if (values == null) {
values = SortedDocValues.EMPTY;
}
toMerge.add(values);
}
consumer.mergeSortedField(field, mergeState, toMerge);
} else {
throw new AssertionError("type=" + type);
toMerge.add(values);
}
consumer.mergeNumericField(field, mergeState, toMerge);
} else if (type == DocValuesType.BINARY) {
List<BinaryDocValues> toMerge = new ArrayList<BinaryDocValues>();
for (AtomicReader reader : mergeState.readers) {
BinaryDocValues values = reader.getBinaryDocValues(field.name);
if (values == null) {
values = BinaryDocValues.EMPTY;
}
toMerge.add(values);
}
consumer.mergeBinaryField(field, mergeState, toMerge);
} else if (type == DocValuesType.SORTED) {
List<SortedDocValues> toMerge = new ArrayList<SortedDocValues>();
for (AtomicReader reader : mergeState.readers) {
SortedDocValues values = reader.getSortedDocValues(field.name);
if (values == null) {
values = SortedDocValues.EMPTY;
}
toMerge.add(values);
}
consumer.mergeSortedField(field, mergeState, toMerge);
} else {
throw new AssertionError("type=" + type);
}
}
success = true;
} finally {
if (success) {
IOUtils.close(consumer);
} else {
IOUtils.closeWhileHandlingException(consumer);
}
}
success = true;
} finally {
if (success) {
IOUtils.close(consumer);
} else {
IOUtils.closeWhileHandlingException(consumer);
}
}
}
private void mergeNorms(SegmentWriteState segmentWriteState) throws IOException {
if (codec.normsFormat() != null) {
DocValuesConsumer consumer = codec.normsFormat().normsConsumer(segmentWriteState);
boolean success = false;
try {
for (FieldInfo field : mergeState.fieldInfos) {
if (field.hasNorms()) {
List<NumericDocValues> toMerge = new ArrayList<NumericDocValues>();
for (AtomicReader reader : mergeState.readers) {
NumericDocValues norms = reader.getNormValues(field.name);
if (norms == null) {
norms = NumericDocValues.EMPTY;
}
toMerge.add(norms);
DocValuesConsumer consumer = codec.normsFormat().normsConsumer(segmentWriteState);
boolean success = false;
try {
for (FieldInfo field : mergeState.fieldInfos) {
if (field.hasNorms()) {
List<NumericDocValues> toMerge = new ArrayList<NumericDocValues>();
for (AtomicReader reader : mergeState.readers) {
NumericDocValues norms = reader.getNormValues(field.name);
if (norms == null) {
norms = NumericDocValues.EMPTY;
}
consumer.mergeNumericField(field, mergeState, toMerge);
toMerge.add(norms);
}
consumer.mergeNumericField(field, mergeState, toMerge);
}
success = true;
} finally {
if (success) {
IOUtils.close(consumer);
} else {
IOUtils.closeWhileHandlingException(consumer);
}
}
success = true;
} finally {
if (success) {
IOUtils.close(consumer);
} else {
IOUtils.closeWhileHandlingException(consumer);
}
}
}