LUCENE-5969: assert -> check

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5969@1627954 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2014-09-27 11:15:24 +00:00
parent 98e9122375
commit 35db73c39e
1 changed files with 11 additions and 4 deletions

View File

@ -19,7 +19,6 @@ package org.apache.lucene.codecs.perfield;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import java.util.Map; import java.util.Map;
@ -148,7 +147,10 @@ public abstract class PerFieldDocValuesFormat extends DocValuesFormat {
final String formatName = format.getName(); final String formatName = format.getName();
String previousValue = field.putAttribute(PER_FIELD_FORMAT_KEY, formatName); String previousValue = field.putAttribute(PER_FIELD_FORMAT_KEY, formatName);
assert field.getDocValuesGen() != -1 || previousValue == null: "formatName=" + formatName + " prevValue=" + previousValue; if (field.getDocValuesGen() == -1 && previousValue != null) {
throw new IllegalStateException("found existing value for " + PER_FIELD_FORMAT_KEY +
", field=" + field.name + ", old=" + previousValue + ", new=" + formatName);
}
Integer suffix = null; Integer suffix = null;
@ -190,7 +192,10 @@ public abstract class PerFieldDocValuesFormat extends DocValuesFormat {
} }
previousValue = field.putAttribute(PER_FIELD_SUFFIX_KEY, Integer.toString(suffix)); previousValue = field.putAttribute(PER_FIELD_SUFFIX_KEY, Integer.toString(suffix));
assert field.getDocValuesGen() != -1 || previousValue == null : "suffix=" + Integer.toString(suffix) + " prevValue=" + previousValue; if (field.getDocValuesGen() == -1 && previousValue != null) {
throw new IllegalStateException("found existing value for " + PER_FIELD_SUFFIX_KEY +
", field=" + field.name + ", old=" + previousValue + ", new=" + suffix);
}
// TODO: we should only provide the "slice" of FIS // TODO: we should only provide the "slice" of FIS
// that this DVF actually sees ... // that this DVF actually sees ...
@ -234,7 +239,9 @@ public abstract class PerFieldDocValuesFormat extends DocValuesFormat {
if (formatName != null) { if (formatName != null) {
// null formatName means the field is in fieldInfos, but has no docvalues! // null formatName means the field is in fieldInfos, but has no docvalues!
final String suffix = fi.getAttribute(PER_FIELD_SUFFIX_KEY); final String suffix = fi.getAttribute(PER_FIELD_SUFFIX_KEY);
assert suffix != null; if (suffix == null) {
throw new IllegalStateException("missing attribute: " + PER_FIELD_SUFFIX_KEY + " for field: " + fieldName);
}
DocValuesFormat format = DocValuesFormat.forName(formatName); DocValuesFormat format = DocValuesFormat.forName(formatName);
String segmentSuffix = getFullSegmentSuffix(readState.segmentSuffix, getSuffix(formatName, suffix)); String segmentSuffix = getFullSegmentSuffix(readState.segmentSuffix, getSuffix(formatName, suffix));
if (!formats.containsKey(segmentSuffix)) { if (!formats.containsKey(segmentSuffix)) {