Apache Lucene open-source search software
LUCENE-3576: check that the order of terms is correct in checkindex
Robert Muirff5b709b3ac6
diff --git a/lucene/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/src/java/org/apache/lucene/index/CheckIndex.javaindex 421d09df730..efac32a9c5c 100644--- a/lucene/src/java/org/apache/lucene/index/CheckIndex.java+++ b/lucene/src/java/org/apache/lucene/index/CheckIndex.java@@ -1341,10 +1341,23 @@ public class CheckIndex {long tfvComputedTermCountForField = 0;long tfvComputedSumTotalTermFreq = 0;+ BytesRef lastTerm = null;+ Comparator<BytesRef> termComp = terms.getComparator();BytesRef term = null;while ((term = termsEnum.next()) != null) {tfvComputedTermCountForField++;+ // make sure terms arrive in order according to+ // the comp+ if (lastTerm == null) {+ lastTerm = BytesRef.deepCopyOf(term);+ } else {+ if (termComp.compare(lastTerm, term) >= 0) {+ throw new RuntimeException("vector terms out of order for doc " + j + ": lastTerm=" + lastTerm + " term=" + term);+ }+ lastTerm.copyBytes(term);+ }+if (termsEnum.docFreq() != 1) {throw new RuntimeException("vector docFreq for doc " + j + ", field " + field + ", term" + term + " != 1");}