lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r748824 - /lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/index/CheckIndex.java
Date Sat, 28 Feb 2009 11:58:59 GMT
Author: mikemccand
Date: Sat Feb 28 11:58:59 2009
New Revision: 748824

URL: http://svn.apache.org/viewvc?rev=748824&view=rev
Log:
LUCENE-1549: add some more checks to CheckIndex

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

Modified: lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/index/CheckIndex.java?rev=748824&r1=748823&r2=748824&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/index/CheckIndex.java Sat Feb
28 11:58:59 2009
@@ -394,13 +394,19 @@
         final int numDocs = reader.numDocs();
         toLoseDocCount = numDocs;
         if (reader.hasDeletions()) {
+          if (reader.deletedDocs.count() != info.getDelCount()) {
+            throw new RuntimeException("delete count mismatch: info=" + info.getDelCount()
+ " vs deletedDocs.count()=" + reader.deletedDocs.count());
+          }
+          if (reader.deletedDocs.count() > reader.maxDoc()) {
+            throw new RuntimeException("too many deleted docs: maxDoc()=" + reader.maxDoc()
+ " vs deletedDocs.count()=" + reader.deletedDocs.count());
+          }
           if (info.docCount - numDocs != info.getDelCount()){
             throw new RuntimeException("delete count mismatch: info=" + info.getDelCount()
+ " vs reader=" + (info.docCount - numDocs));
           }
           segInfoStat.numDeleted = info.docCount - numDocs;
           msg("OK [" + (segInfoStat.numDeleted) + " deleted docs]");
         } else {
-          if (info.getDelCount() != 0){
+          if (info.getDelCount() != 0) {
             throw new RuntimeException("delete count mismatch: info=" + info.getDelCount()
+ " vs reader=" + (info.docCount - numDocs));
           }
           msg("OK");
@@ -431,6 +437,8 @@
         long termCount = 0;
         long totFreq = 0;
         long totPos = 0;
+        final int maxDoc = reader.maxDoc();
+
         while(termEnum.next()) {
           termCount++;
           final Term term = termEnum.term();
@@ -445,6 +453,9 @@
             final int freq = termPositions.freq();
             if (doc <= lastDoc)
               throw new RuntimeException("term " + term + ": doc " + doc + " <= lastDoc
" + lastDoc);
+            if (doc >= maxDoc)
+              throw new RuntimeException("term " + term + ": doc " + doc + " >= maxDoc
" + maxDoc);
+
             lastDoc = doc;
             if (freq <= 0)
               throw new RuntimeException("term " + term + ": doc " + doc + ": freq " + freq
+ " is out of bounds");



Mime
View raw message