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/03/16 18:07:37 UTC

svn commit: r1301650 - /lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java

Author: rmuir
Date: Fri Mar 16 17:07:37 2012
New Revision: 1301650

URL: http://svn.apache.org/viewvc?rev=1301650&view=rev
Log:
LUCENE-3878: add basic liveDocs checks to CheckIndex

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

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java?rev=1301650&r1=1301649&r2=1301650&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java Fri Mar 16 17:07:37 2012
@@ -20,7 +20,6 @@ package org.apache.lucene.index;
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
-import java.lang.reflect.Array;
 import java.text.NumberFormat;
 import java.util.ArrayList;
 import java.util.Comparator;
@@ -553,12 +552,36 @@ public class CheckIndex {
           if (info.docCount - numDocs != info.getDelCount()) {
             throw new RuntimeException("delete count mismatch: info=" + info.getDelCount() + " vs reader=" + (info.docCount - numDocs));
           }
+          Bits liveDocs = reader.getLiveDocs();
+          if (liveDocs == null) {
+            throw new RuntimeException("segment should have deletions, but liveDocs is null");
+          } else {
+            int numLive = 0;
+            for (int j = 0; j < liveDocs.length(); j++) {
+              if (liveDocs.get(j)) {
+                numLive++;
+              }
+            }
+            if (numLive != numDocs) {
+              throw new RuntimeException("liveDocs count mismatch: info=" + numDocs + ", vs bits=" + numLive);
+            }
+          }
+          
           segInfoStat.numDeleted = info.docCount - numDocs;
           msg("OK [" + (segInfoStat.numDeleted) + " deleted docs]");
         } else {
           if (info.getDelCount() != 0) {
             throw new RuntimeException("delete count mismatch: info=" + info.getDelCount() + " vs reader=" + (info.docCount - numDocs));
           }
+          Bits liveDocs = reader.getLiveDocs();
+          if (liveDocs != null) {
+            // its ok for it to be non-null here, as long as none are set right?
+            for (int j = 0; j < liveDocs.length(); j++) {
+              if (!liveDocs.get(j)) {
+                throw new RuntimeException("liveDocs mismatch: info says no deletions but doc " + j + " is deleted.");
+              }
+            }
+          }
           msg("OK");
         }
         if (reader.maxDoc() != info.docCount)