You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Michael McCandless (JIRA)" <ji...@apache.org> on 2009/12/06 12:43:18 UTC
[jira] Resolved: (LUCENE-2119) If you pass Integer.MAX_VALUE as 2nd
param to search(Query, int) you hit unexpected NegativeArraySizeException
[ https://issues.apache.org/jira/browse/LUCENE-2119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael McCandless resolved LUCENE-2119.
----------------------------------------
Resolution: Fixed
Thanks Paul!
> If you pass Integer.MAX_VALUE as 2nd param to search(Query, int) you hit unexpected NegativeArraySizeException
> --------------------------------------------------------------------------------------------------------------
>
> Key: LUCENE-2119
> URL: https://issues.apache.org/jira/browse/LUCENE-2119
> Project: Lucene - Java
> Issue Type: Bug
> Components: Search
> Reporter: Michael McCandless
> Assignee: Michael McCandless
> Priority: Minor
> Fix For: 3.1
>
> Attachments: LUCENE-2119.patch
>
>
> Note that this is a nonsense value to pass in, since our PQ impl allocates the array up front.
> It's because PQ takes 1+ this value (which wraps to -1), and attempts to allocate that. We should bounds check it, and drop PQ size by one in this case.
> Better, maybe: in IndexSearcher, if that n is ever > maxDoc(), set it to maxDoc().
> This trips users up fairly often because they assume our PQ doesn't statically pre-allocate (a reasonable assumption...).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
RE: [jira] Resolved: (LUCENE-2119) If you pass Integer.MAX_VALUE as 2nd param to search(Query, int) you hit unexpected NegativeArraySizeException
Posted by Uwe Schindler <uw...@thetaphi.de>.
> On Sun, Dec 06, 2009 at 05:31:53PM -0500, Erick Erickson wrote:
> > This may be a silly question, and I admit that I haven't looked a the
> code,
> > but was there a good reason to +1 it in the first place or was that just
> > paranoia to prevent off-by-one errors?
>
> IIRC, this implementation of the priority queue algo leaves open slot 0 to
> simplify internal calculations. It was that way when I ported 1.4.3, and
> I
> doubt that's changed.
Thats still the same. Because calculations in heaps are simplier when
1-based. Because of that heap[0] is unused.
> > If there *was* a valid reason, might it make sense to
> > +1 min(nDocs, maxDoc())?
>
> I think the patch is fine. It's really only needed to provide a more
> accurate
> error message in the event somebody specifies that they want
> Integer.MAX_VALUE
> elements, not realizing that they will be allocated up front rather than
> lazily -- they'll get an OOME rather than a NegativeArraySizeException.
The new patch is more intelligent, it will not allocate such a big queue as
far as I have seen. It takes the numDocs() of index reader/searcher into
account.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: [jira] Resolved: (LUCENE-2119) If you pass Integer.MAX_VALUE as 2nd param to search(Query, int) you hit unexpected NegativeArraySizeException
Posted by Marvin Humphrey <ma...@rectangular.com>.
On Sun, Dec 06, 2009 at 05:31:53PM -0500, Erick Erickson wrote:
> This may be a silly question, and I admit that I haven't looked a the code,
> but was there a good reason to +1 it in the first place or was that just
> paranoia to prevent off-by-one errors?
IIRC, this implementation of the priority queue algo leaves open slot 0 to
simplify internal calculations. It was that way when I ported 1.4.3, and I
doubt that's changed.
> If there *was* a valid reason, might it make sense to
> +1 min(nDocs, maxDoc())?
I think the patch is fine. It's really only needed to provide a more accurate
error message in the event somebody specifies that they want Integer.MAX_VALUE
elements, not realizing that they will be allocated up front rather than
lazily -- they'll get an OOME rather than a NegativeArraySizeException.
Cheers,
Marvin Humphrey
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: [jira] Resolved: (LUCENE-2119) If you pass Integer.MAX_VALUE as
2nd param to search(Query, int) you hit unexpected NegativeArraySizeException
Posted by Erick Erickson <er...@gmail.com>.
This may be a silly question, and I admit that I haven't looked a the code,
but was there a good reason to +1 it in the first place or was that just
paranoia
to prevent off-by-one errors? If there *was* a valid reason, might it make
sense to +1 min(nDocs, maxDoc())?
Erick
On Sun, Dec 6, 2009 at 6:43 AM, Michael McCandless (JIRA)
<ji...@apache.org>wrote:
>
> [
> https://issues.apache.org/jira/browse/LUCENE-2119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel]
>
> Michael McCandless resolved LUCENE-2119.
> ----------------------------------------
>
> Resolution: Fixed
>
> Thanks Paul!
>
> > If you pass Integer.MAX_VALUE as 2nd param to search(Query, int) you hit
> unexpected NegativeArraySizeException
> >
> --------------------------------------------------------------------------------------------------------------
> >
> > Key: LUCENE-2119
> > URL: https://issues.apache.org/jira/browse/LUCENE-2119
> > Project: Lucene - Java
> > Issue Type: Bug
> > Components: Search
> > Reporter: Michael McCandless
> > Assignee: Michael McCandless
> > Priority: Minor
> > Fix For: 3.1
> >
> > Attachments: LUCENE-2119.patch
> >
> >
> > Note that this is a nonsense value to pass in, since our PQ impl
> allocates the array up front.
> > It's because PQ takes 1+ this value (which wraps to -1), and attempts to
> allocate that. We should bounds check it, and drop PQ size by one in this
> case.
> > Better, maybe: in IndexSearcher, if that n is ever > maxDoc(), set it to
> maxDoc().
> > This trips users up fairly often because they assume our PQ doesn't
> statically pre-allocate (a reasonable assumption...).
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>
>