mirror of https://github.com/apache/lucene.git
fix ord bounds check to check maxOrd (not number of docs), and document bug in 4.0 codec
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1438129 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e6dbf827db
commit
ff3e225780
|
@ -1305,11 +1305,13 @@ public class CheckIndex {
|
||||||
// check sorted bytes
|
// check sorted bytes
|
||||||
SortedSource sortedValues = values.asSortedSource();
|
SortedSource sortedValues = values.asSortedSource();
|
||||||
Comparator<BytesRef> comparator = sortedValues.getComparator();
|
Comparator<BytesRef> comparator = sortedValues.getComparator();
|
||||||
|
int maxOrd = sortedValues.getValueCount() - 1;
|
||||||
|
FixedBitSet seenOrds = new FixedBitSet(sortedValues.getValueCount());
|
||||||
int lastOrd = -1;
|
int lastOrd = -1;
|
||||||
BytesRef lastBytes = new BytesRef();
|
BytesRef lastBytes = new BytesRef();
|
||||||
for (int i = 0; i < expectedDocs; i++) {
|
for (int i = 0; i < expectedDocs; i++) {
|
||||||
int ord = sortedValues.ord(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);
|
throw new RuntimeException("field: " + fieldName + " ord is out of bounds: " + ord);
|
||||||
}
|
}
|
||||||
BytesRef bytes = new BytesRef();
|
BytesRef bytes = new BytesRef();
|
||||||
|
@ -1323,6 +1325,13 @@ public class CheckIndex {
|
||||||
}
|
}
|
||||||
lastOrd = ord;
|
lastOrd = ord;
|
||||||
lastBytes = bytes;
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue