I see. Well, since all I care about is having two arrays of the same size, what if I grow 'docs' and then make 'offsets' exactly the same size? Since they start at the same size, this should work? Although may not be super optimized for int/long array growing.
Shai On Sun, Mar 10, 2013 at 2:31 PM, Michael McCandless < [email protected]> wrote: > On Sun, Mar 10, 2013 at 7:25 AM, <[email protected]> wrote: > > Author: shaie > > Date: Sun Mar 10 11:25:45 2013 > > New Revision: 1454836 > > > > URL: http://svn.apache.org/r1454836 > > Log: > > SortingAtomicReader did not grow the arrays consistently > > > > Modified: > > lucene/dev/branches/branch_4x/ (props changed) > > lucene/dev/branches/branch_4x/lucene/ (props changed) > > lucene/dev/branches/branch_4x/lucene/misc/ (props changed) > > > lucene/dev/branches/branch_4x/lucene/misc/src/java/org/apache/lucene/index/sorter/SortingAtomicReader.java > > > > Modified: > lucene/dev/branches/branch_4x/lucene/misc/src/java/org/apache/lucene/index/sorter/SortingAtomicReader.java > > URL: > http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/misc/src/java/org/apache/lucene/index/sorter/SortingAtomicReader.java?rev=1454836&r1=1454835&r2=1454836&view=diff > > > ============================================================================== > > --- > lucene/dev/branches/branch_4x/lucene/misc/src/java/org/apache/lucene/index/sorter/SortingAtomicReader.java > (original) > > +++ > lucene/dev/branches/branch_4x/lucene/misc/src/java/org/apache/lucene/index/sorter/SortingAtomicReader.java > Sun Mar 10 11:25:45 2013 > > @@ -447,8 +447,8 @@ public class SortingAtomicReader extends > > int i = 0; > > while ((doc = in.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { > > if (i == docs.length) { > > - docs = ArrayUtil.grow(docs, i + 1); > > - offsets = ArrayUtil.grow(offsets, i + 1); > > + docs = ArrayUtil.grow(docs, docs.length + 1); > > + offsets = ArrayUtil.grow(offsets, offsets.length + 1); > > } > > docs[i] = old2new[doc]; > > offsets[i] = out.getFilePointer(); > > This is a little dangerous: the progression of sizes from > ArrayUtil.grow is not necessarily the same for an int[] and a long[] > ... I think it may be in this case because you start with size 32. > It's better to separately check each array and grow if needed ... > > Mike McCandless > > http://blog.mikemccandless.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
