lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nadav Har'El (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-504) FuzzyQuery produces a "java.lang.NegativeArraySizeException" in PriorityQueue.initialize if I use Integer.MAX_VALUE as BooleanQuery.MaxClauseCount
Date Wed, 14 Jun 2006 10:46:30 GMT
    [ http://issues.apache.org/jira/browse/LUCENE-504?page=comments#action_12416168 ] 

Nadav Har'El commented on LUCENE-504:
-------------------------------------

Hi Doron and Otis,

My view is that this bug is a problem in FuzzyQuery, not in PriorityQueue or BooleanQuery.
It is the caller's duty to create a priority queue with a sensible size, and it's not BooleanQuery's
fault that other classes are using its getMaxClauseCount() wrongly. Moreover, changing PriorityQueue
or BooleanQuery in the way Doron did, might potentially have side-effects because they are
used in many places in Lucene. How do we know that nowhere in Lucene will we ever need a priority
queue with a million elements?

Therefore I suggest a different patch, changing only FuzzyQuery. 

he idea in the patch I'm attaching is that while FuzzyQuery *is allowed to* create BooleanQuery.getMaxClauseCount()
clauses, it doesn't have to do so, and doesn't need to create a priority queue of that size
when this number is huge. I added to FuzzyQuery its own maxClauseCount (with per-instance
getter/setter methods)  and FuzzyQuery will never try to create more than this number of clauses,
even if Boolean.getMaxClauseCount() is huge.

I set FuzzyQuery's default maxClauseCount to 1024, for backward compatibility (this is what
happens today when you use BooleanQuery's defaults). However, it is likely that a user will
want to set this number much lower than that. In fact, the whole idea of the priority queue
is that it may be enough to take only a small number the most similar terms, so setting a
FuzzyQuery's maxClauseCount to 100 or even 10 makes sense to me. This new feature is an added
benefit of my patch.

My patch also includes Javadoc changes describing the new feature, and a new test case that
failed before the fix, and succeeds after this patch. 

> FuzzyQuery produces a "java.lang.NegativeArraySizeException" in PriorityQueue.initialize
if I use Integer.MAX_VALUE as BooleanQuery.MaxClauseCount
> --------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: LUCENE-504
>          URL: http://issues.apache.org/jira/browse/LUCENE-504
>      Project: Lucene - Java
>         Type: Bug

>   Components: Search
>     Versions: 1.9
>     Reporter: Joerg Henss
>     Priority: Minor
>  Attachments: BooleanQuery.java.diff, PriorityQueue.java.diff, TestFuzzyQueryError.java
>
> PriorityQueue creates an "java.lang.NegativeArraySizeException" when initialized with
Integer.MAX_VALUE, because Integer overflows. I think this could be a general problem with
PriorityQueue. The Error occured when I set BooleanQuery.MaxClauseCount to Integer.MAX_VALUE
and user a FuzzyQuery for searching.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message