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 2013/01/24 20:10:36 UTC

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

Author: rmuir
Date: Thu Jan 24 19:10:35 2013
New Revision: 1438129

URL: http://svn.apache.org/viewvc?rev=1438129&view=rev
Log:
fix ord bounds check to check maxOrd (not number of docs), and document bug in 4.0 codec

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=1438129&r1=1438128&r2=1438129&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 Thu Jan 24 19:10:35 2013
@@ -1305,11 +1305,13 @@ public class CheckIndex {
       // check sorted bytes
       SortedSource sortedValues = values.asSortedSource();
       Comparator<BytesRef> comparator = sortedValues.getComparator();
+      int maxOrd = sortedValues.getValueCount() - 1;
+      FixedBitSet seenOrds = new FixedBitSet(sortedValues.getValueCount());
       int lastOrd = -1;
       BytesRef lastBytes = new BytesRef();
       for (int i = 0; i < expectedDocs; i++) {
         int ord = sortedValues.ord(i);
-        if (ord < 0 || ord > expectedDocs) {
+        if (ord < 0 || ord > maxOrd) {
           throw new RuntimeException("field: " + fieldName + " ord is out of bounds: " + ord);
         }
         BytesRef bytes = new BytesRef();
@@ -1323,6 +1325,13 @@ public class CheckIndex {
         }
         lastOrd = ord;
         lastBytes = bytes;
+        seenOrds.set(ord);
+      }
+      if (seenOrds.cardinality() != sortedValues.getValueCount()) {
+        // TODO: find the bug here and figure out a workaround (we can implement in LUCENE-4547's back compat layer maybe)
+        // basically ord 0 is unused by any docs: so the sortedbytes ords are all off-by-one
+        // does it always happen? e.g. maybe only if there are missing values? or a bug in its merge optimizations?
+        // throw new RuntimeException("dv for field: " + fieldName + " has holes in its ords, valueCount=" + sortedValues.getValueCount() + " but only used: " + seenOrds.cardinality());
       }
     }
   }