You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/02/21 11:58:24 UTC

svn commit: r1291705 - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/contrib/spellchecker/ lucene/core/src/java/org/apache/lucene/index/CheckIndex.java solr/ solr/core/

Author: rmuir
Date: Tue Feb 21 10:58:24 2012
New Revision: 1291705

URL: http://svn.apache.org/viewvc?rev=1291705&view=rev
Log:
sanity check term fields against fieldinfos, and term order in checkindex

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/lucene/contrib/spellchecker/   (props changed)
    lucene/dev/branches/branch_3x/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/core/   (props changed)

Modified: lucene/dev/branches/branch_3x/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java?rev=1291705&r1=1291704&r2=1291705&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/dev/branches/branch_3x/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java Tue Feb 21 10:58:24 2012
@@ -559,7 +559,7 @@ public class CheckIndex {
         segInfoStat.fieldNormStatus = testFieldNorms(fieldInfos, reader);
 
         // Test the Term Index
-        segInfoStat.termIndexStatus = testTermIndex(info, reader);
+        segInfoStat.termIndexStatus = testTermIndex(info, fieldInfos, reader);
 
         // Test Stored Fields
         segInfoStat.storedFieldStatus = testStoredFields(info, reader, nf);
@@ -653,7 +653,7 @@ public class CheckIndex {
   /**
    * Test the term index.
    */
-  private Status.TermIndexStatus testTermIndex(SegmentInfo info, SegmentReader reader) {
+  private Status.TermIndexStatus testTermIndex(SegmentInfo info, FieldInfos fieldInfos, SegmentReader reader) {
     final Status.TermIndexStatus status = new Status.TermIndexStatus();
 
     final IndexSearcher is = new IndexSearcher(reader);
@@ -671,11 +671,27 @@ public class CheckIndex {
 
       final int maxDoc = reader.maxDoc();
       Term lastTerm = null;
+      String lastField = null;
       while (termEnum.next()) {
         status.termCount++;
         final Term term = termEnum.term();
-        lastTerm = term;
 
+        if (lastTerm != null && term.compareTo(lastTerm) <= 0) {
+          throw new RuntimeException("terms out of order: lastTerm=" + lastTerm + " term=" + term);
+        }
+        lastTerm = term;
+        
+        if (term.field != lastField) {
+          // field change: verify its in fieldinfos, and that its indexed.
+          FieldInfo fi = fieldInfos.fieldInfo(term.field);
+          if (fi == null) {
+            throw new RuntimeException("terms inconsistent with fieldInfos, no fieldInfos for: " + term.field);
+          }
+          if (!fi.isIndexed) {
+            throw new RuntimeException("terms inconsistent with fieldInfos, isIndexed == false for: " + term.field);
+          }
+          lastField = term.field;
+        }
         final int docFreq = termEnum.docFreq();
         if (docFreq <= 0) {
           throw new RuntimeException("docfreq: " + docFreq + " is out of bounds");