lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1201363 - /lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/CheckIndex.java
Date Sat, 12 Nov 2011 23:58:49 GMT
Author: rmuir
Date: Sat Nov 12 23:58:48 2011
New Revision: 1201363

URL: http://svn.apache.org/viewvc?rev=1201363&view=rev
Log:
LUCENE-2621: start beefing up CheckIndex.testTermVectors

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=1201363&r1=1201362&r2=1201363&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
Sat Nov 12 23:58:48 2011
@@ -1142,15 +1142,38 @@ public class CheckIndex {
         infoStream.print("    test: term vectors........");
       }
 
+      // TODO: maybe we can factor out testTermIndex and reuse here?
       final Bits liveDocs = reader.getLiveDocs();
       for (int j = 0; j < info.docCount; ++j) {
         if (liveDocs == null || liveDocs.get(j)) {
           status.docCount++;
           Fields tfv = reader.getTermVectors(j);
           if (tfv != null) {
+            int tfvComputedFieldCount = 0;
+            int tfvComputedTermCount = 0;
+
             FieldsEnum fieldsEnum = tfv.iterator();
-            while(fieldsEnum.next() != null) {
+            String field = null;
+            while((field = fieldsEnum.next()) != null) {
               status.totVectors++;
+              tfvComputedFieldCount++;
+              
+              Terms terms = tfv.terms(field);
+              TermsEnum termsEnum = terms.iterator();
+              while (termsEnum.next() != null) {
+                tfvComputedTermCount++;
+              }
+            }
+            
+            // 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);
+            }
+            
+            long tfvUniqueTermCount = tfv.getUniqueTermCount();
+            if (tfvUniqueTermCount != -1 && tfvUniqueTermCount != tfvComputedTermCount)
{
+              throw new RuntimeException("vector term count for doc " + j + "=" + tfvUniqueTermCount
+ " != recomputed uniqueTermCount=" + tfvComputedTermCount);
             }
           }
         }



Mime
View raw message