You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by mi...@apache.org on 2009/02/28 13:01:19 UTC

svn commit: r748826 - /lucene/java/trunk/src/java/org/apache/lucene/index/CheckIndex.java

Author: mikemccand
Date: Sat Feb 28 12:01:19 2009
New Revision: 748826

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

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/CheckIndex.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/CheckIndex.java?rev=748826&r1=748825&r2=748826&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/CheckIndex.java Sat Feb 28 12:01:19 2009
@@ -396,13 +396,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");
@@ -433,6 +439,8 @@
         long termCount = 0;
         long totFreq = 0;
         long totPos = 0;
+        final int maxDoc = reader.maxDoc();
+
         while(termEnum.next()) {
           termCount++;
           final Term term = termEnum.term();
@@ -447,6 +455,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");