make CheckIndex a bit more anal about ghost fields

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1166928 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-09-08 22:24:40 +00:00
parent 46985446cf
commit 896afc4c01
1 changed files with 76 additions and 64 deletions

View File

@ -886,6 +886,17 @@ public class CheckIndex {
}
final Terms fieldTerms = fields.terms(field);
if (fieldTerms == null) {
// Unusual: the FieldsEnum returned a field but
// the Terms for that field is null; this should
// only happen if it's a ghost field (field with
// no terms, eg there used to be terms but all
// docs got deleted and then merged away):
// make sure TermsEnum is empty:
if (fieldsEnum.terms().next() != null) {
throw new RuntimeException("Fields.terms(field=" + field + ") returned null yet the field appears to have terms");
}
} else {
if (fieldTerms instanceof BlockTreeTermsReader.FieldReader) {
final BlockTreeTermsReader.Stats stats = ((BlockTreeTermsReader.FieldReader) fieldTerms).computeStats();
assert stats != null;
@ -971,6 +982,7 @@ public class CheckIndex {
}
}
}
}
msg("OK [" + status.termCount + " terms; " + status.totFreq + " terms/docs pairs; " + status.totPos + " tokens]");