lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: svn commit: r1454836 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/misc/ lucene/misc/src/java/org/apache/lucene/index/sorter/SortingAtomicReader.java
Date Sun, 10 Mar 2013 12:31:38 GMT
On Sun, Mar 10, 2013 at 7:25 AM,  <shaie@apache.org> 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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message