move docValuesType checking down to FieldInfo

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1439722 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2013-01-29 00:49:18 +00:00
parent 905cf63c0e
commit 726659bf9a
2 changed files with 4 additions and 6 deletions

View File

@ -55,12 +55,7 @@ final class DocValuesProcessor extends StoredFieldsConsumer {
// nocommit: these checks are duplicated everywhere
final 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) {

View File

@ -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();
}