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 2011/11/13 02:52:12 UTC

svn commit: r1201387 - /lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/CheckIndex.java

Author: rmuir
Date: Sun Nov 13 01:52:12 2011
New Revision: 1201387

URL: http://svn.apache.org/viewvc?rev=1201387&view=rev
Log:
LUCENE-2621: verify uniqueFieldCount in the terms index check too

Modified:
    lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/CheckIndex.java

Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/CheckIndex.java?rev=1201387&r1=1201386&r2=1201387&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/CheckIndex.java Sun Nov 13 01:52:12 2011
@@ -676,6 +676,7 @@ public class CheckIndex {
         infoStream.print("    test: terms, freq, prox...");
       }
 
+      int computedFieldCount = 0;
       final Fields fields = reader.fields();
       if (fields == null) {
         msg("OK [no fields/terms]");
@@ -692,6 +693,8 @@ public class CheckIndex {
           break;
         }
         
+        computedFieldCount++;
+        
         final TermsEnum terms = fieldsEnum.terms();
         assert terms != null;
         boolean hasOrd = true;
@@ -997,6 +1000,17 @@ public class CheckIndex {
           }
         }
       }
+      
+      int fieldCount = fields.getUniqueFieldCount();
+      
+      if (fieldCount != -1) {
+        if (fieldCount < 0) {
+          throw new RuntimeException("invalid fieldCount: " + fieldCount);
+        }
+        if (fieldCount != computedFieldCount) {
+          throw new RuntimeException("fieldCount mismatch " + fieldCount + " vs recomputed field count " + computedFieldCount);
+        }
+      }
 
       // for most implementations, this is boring (just the sum across all fields)
       // but codecs that don't work per-field like preflex actually implement this,
@@ -1250,7 +1264,6 @@ public class CheckIndex {
               tfvComputedTermCount += tfvComputedTermCountForField;
             }
             
-            // TODO: testTermIndex should check this stat too!
             int tfvUniqueFieldCount = tfv.getUniqueFieldCount();
             if (tfvUniqueFieldCount != -1 && tfvUniqueFieldCount != tfvComputedFieldCount) {
               throw new RuntimeException("vector field count for doc " + j + "=" + tfvUniqueFieldCount + " != recomputed uniqueFieldCount=" + tfvComputedFieldCount);