move normDVType checking into FieldInfo; add nocommits

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1439727 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2013-01-29 01:18:13 +00:00
parent 348ed1d255
commit 7e683d8ed0
3 changed files with 8 additions and 13 deletions

View File

@ -232,6 +232,9 @@ public final class FieldInfo {
// nocommit type is always number? should we remove this?
void setNormValueType(DocValuesType type) {
if (normType != null && normType != type) {
throw new IllegalArgumentException("cannot change Norm type from " + normType + " to " + type + " for field \"" + name + "\"");
}
normType = type;
assert checkConsistency();
}

View File

@ -213,15 +213,17 @@ public class FieldInfos implements Iterable<FieldInfo> {
* Sets the given field number and name if not yet set.
*/
// nocommit: why is docvalues involved with global field numbers?
// nocommit: and is it even tested...
synchronized void setIfNotSet(int fieldNumber, String fieldName, DocValuesType dvType) {
final Integer boxedFieldNumber = Integer.valueOf(fieldNumber);
if (!numberToName.containsKey(boxedFieldNumber)
&& !nameToNumber.containsKey(fieldName)
&& !docValuesType.containsKey(fieldName)) {
&& !docValuesType.containsKey(dvType)) {
numberToName.put(boxedFieldNumber, fieldName);
nameToNumber.put(fieldName, boxedFieldNumber);
docValuesType.put(fieldName, dvType);
} else {
// nocommit should this be a real check?
assert containsConsistent(boxedFieldNumber, fieldName, dvType);
}
}
@ -319,22 +321,10 @@ public class FieldInfos implements Iterable<FieldInfo> {
fi.update(isIndexed, storeTermVector, omitNorms, storePayloads, indexOptions);
if (docValues != null) {
DocValuesType currentDVType = fi.getDocValuesType();
if (currentDVType == null) {
fi.setDocValuesType(docValues);
} else if (currentDVType != docValues) {
throw new IllegalArgumentException("cannot change DocValues type from " + currentDVType + " to " + docValues + " for field \"" + name + "\"");
}
fi.setDocValuesType(docValues);
}
if (!fi.omitsNorms() && normType != null) {
DocValuesType currentDVType = fi.getNormType();
if (currentDVType == null) {
fi.setNormValueType(docValues);
} else if (currentDVType != normType) {
throw new IllegalArgumentException("cannot change Norm type from " + currentDVType + " to " + normType + " for field \"" + name + "\"");
}
fi.setNormValueType(normType);
}
}

View File

@ -763,6 +763,8 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
private FieldNumbers getFieldNumberMap() throws IOException {
final FieldNumbers map = new FieldNumbers();
// nocommit for a 4.0 index that has inconsistent DV
// types ... this will throw exc on init of IW?
for(SegmentInfoPerCommit info : segmentInfos) {
for(FieldInfo fi : getFieldInfos(info.info)) {
map.addOrGet(fi.name, fi.number, fi.getDocValuesType());