From 7c7898fc126076862217ac578a1779d811e5eeb5 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 19 Nov 2012 21:38:45 +0000 Subject: [PATCH] more checkindex git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1411436 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/java/org/apache/lucene/index/CheckIndex.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java index 9ea399405b7..7f380795aa1 100644 --- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java +++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java @@ -1394,13 +1394,22 @@ public class CheckIndex { private void checkSortedDocValues(FieldInfo fi, SegmentReader reader, SortedDocValues dv) { checkBinaryDocValues(fi, reader, dv); final int maxOrd = dv.getValueCount()-1; + FixedBitSet seenOrds = new FixedBitSet(dv.getValueCount()); int maxOrd2 = -1; for (int i = 0; i < reader.maxDoc(); i++) { - maxOrd2 = Math.max(maxOrd2, dv.getOrd(i)); + int ord = dv.getOrd(i); + if (ord < 0 || ord > maxOrd) { + throw new RuntimeException("ord out of bounds: " + ord); + } + maxOrd2 = Math.max(maxOrd2, ord); + seenOrds.set(ord); } if (maxOrd != maxOrd2) { throw new RuntimeException("dv for field: " + fi.name + " reports wrong maxOrd=" + maxOrd + " but this is not the case: " + maxOrd2); } + if (seenOrds.cardinality() != dv.getValueCount()) { + throw new RuntimeException("dv for field: " + fi.name + " has holes in its ords, valueCount=" + dv.getValueCount() + " but only used: " + seenOrds.cardinality()); + } BytesRef lastValue = null; BytesRef scratch = new BytesRef(); for (int i = 0; i <= maxOrd; i++) {