make sure docs and offsets are the same length

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1454849 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2013-03-10 13:37:20 +00:00
parent cf803eaf92
commit 3071009fda
1 changed files with 5 additions and 1 deletions

View File

@ -448,7 +448,11 @@ public class SortingAtomicReader extends FilterAtomicReader {
while ((doc = in.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { while ((doc = in.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
if (i == docs.length) { if (i == docs.length) {
docs = ArrayUtil.grow(docs, docs.length + 1); docs = ArrayUtil.grow(docs, docs.length + 1);
offsets = ArrayUtil.grow(offsets, offsets.length + 1); // don't grow() offsets since growing pattern for long and int is not the same.
// since we want docs and offsets at the same length, just grow it manually.
long[] tmp = new long[docs.length];
System.arraycopy(offsets, 0, tmp, 0, offsets.length);
offsets = tmp;
} }
docs[i] = old2new[doc]; docs[i] = old2new[doc];
offsets[i] = out.getFilePointer(); offsets[i] = out.getFilePointer();