mirror of https://github.com/apache/lucene.git
The base calculation in ReaderUtil.Gather is so complicated, add some assert to verify that it is still correct. The code lead to another bug I fixed in CompositeReaderContext long time ago (at least it explains why Simon did it wrong...)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1351129 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7f9d6b89aa
commit
bcaa52c562
|
@ -111,6 +111,7 @@ public final class CompositeReaderContext extends IndexReaderContext {
|
||||||
children[i] = build(newParent, sequentialSubReaders[i], i, newDocBase);
|
children[i] = build(newParent, sequentialSubReaders[i], i, newDocBase);
|
||||||
newDocBase += sequentialSubReaders[i].maxDoc();
|
newDocBase += sequentialSubReaders[i].maxDoc();
|
||||||
}
|
}
|
||||||
|
assert newDocBase == cr.maxDoc();
|
||||||
return newParent;
|
return newParent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,20 +101,21 @@ public final class ReaderUtil {
|
||||||
return run(docBase, topReader);
|
return run(docBase, topReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int run(int base, IndexReader reader) throws IOException {
|
private int run(final int base, final IndexReader reader) throws IOException {
|
||||||
if (reader instanceof AtomicReader) {
|
if (reader instanceof AtomicReader) {
|
||||||
// atomic reader
|
// atomic reader
|
||||||
add(base, (AtomicReader) reader);
|
add(base, (AtomicReader) reader);
|
||||||
base += reader.maxDoc();
|
return base + reader.maxDoc();
|
||||||
} else {
|
} else {
|
||||||
assert reader instanceof CompositeReader : "must be a composite reader";
|
assert reader instanceof CompositeReader : "must be a composite reader";
|
||||||
|
int newBase = base;
|
||||||
IndexReader[] subReaders = ((CompositeReader) reader).getSequentialSubReaders();
|
IndexReader[] subReaders = ((CompositeReader) reader).getSequentialSubReaders();
|
||||||
for (int i = 0; i < subReaders.length; i++) {
|
for (int i = 0; i < subReaders.length; i++) {
|
||||||
base = run(base, subReaders[i]);
|
newBase = run(newBase, subReaders[i]);
|
||||||
}
|
}
|
||||||
|
assert newBase == base + reader.maxDoc();
|
||||||
|
return newBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
return base;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void add(int base, AtomicReader r) throws IOException;
|
protected abstract void add(int base, AtomicReader r) throws IOException;
|
||||||
|
|
Loading…
Reference in New Issue