Apache Lucene open-source search software
move docValuesType checking down to FieldInfo
Michael McCandless726659bf9ae5
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocValuesProcessor.java b/lucene/core/src/java/org/apache/lucene/index/DocValuesProcessor.javaindex e89cff08c79..4d0160f1d48 100644--- a/lucene/core/src/java/org/apache/lucene/index/DocValuesProcessor.java+++ b/lucene/core/src/java/org/apache/lucene/index/DocValuesProcessor.java@@ -55,12 +55,7 @@ final class DocValuesProcessor extends StoredFieldsConsumer {// nocommit: these checks are duplicated everywherefinal DocValuesType dvType = field.fieldType().docValueType();if (dvType != null) {- DocValuesType currentDVType = fieldInfo.getDocValuesType();- if (currentDVType == null) {- fieldInfo.setDocValuesType(dvType);- } else if (currentDVType != dvType) {- throw new IllegalArgumentException("cannot change DocValues type from " + currentDVType + " to " + dvType + " for field \"" + fieldInfo.name + "\"");- }+ fieldInfo.setDocValuesType(dvType);if (dvType == DocValuesType.BINARY) {addBinaryField(fieldInfo, docID, field.binaryValue());} else if (dvType == DocValuesType.SORTED) {diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfo.javaindex 95cfc96ebde..cda6d56f100 100644--- a/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java+++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java@@ -185,6 +185,9 @@ public final class FieldInfo {}void setDocValuesType(DocValuesType type) {+ if (docValueType != null && docValueType != type) {+ throw new IllegalArgumentException("cannot change DocValues type from " + docValueType + " to " + type + " for field \"" + name + "\"");+ }docValueType = type;assert checkConsistency();}