[ 
https://issues.apache.org/jira/browse/LUCENE-6427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14496329#comment-14496329
 ] 

Luc Vanlerberghe commented on LUCENE-6427:
------------------------------------------

* I wasn't sure whether to include the comment or not, but decided to do so 
anyway since the check is in an assert (and hence will only be triggered when 
asserts are enabled).  I used an assert to avoid affecting performance on 
proper use. I think the user should be warned not to recycle any 'old' 
FixedBitSet that happens not to have any bits set in the numbits range without 
clearing it properly.  Perhaps the doc comment should only be left on the 
constructor and moved to a 'normal' comment for other methods.
* I needed the checkEmpty method :) I do use nextSetBit(0) for now, but that 
will throw an exception if the BitSet has 0 size...
* I did use the random() object, I just stored it in a local variable because I 
needed it several times in a row (should be ok from reading the doc comment on 
LuceneTestCase.random())

On ensureCapacity: ok for opening an new issue after this one is closed...


> BitSet fixes - assert on presence of 'ghost bits' and others
> ------------------------------------------------------------
>
>                 Key: LUCENE-6427
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6427
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/other
>            Reporter: Luc Vanlerberghe
>
> Fixes after reviewing org.apache.lucene.util.FixedBitSet, LongBitSet and 
> corresponding tests:
> * Some methods rely on the fact that no bits are set after numBits (what I 
> call 'ghost' bits here).
> ** cardinality, nextSetBit, intersects and others may yield wrong results
> ** If ghost bits are present, they may become visible after ensureCapacity is 
> called.
> ** The tests deliberately create bitsets with ghost bits, but then do not 
> detect these failures
> * FixedBitSet.cardinality scans the complete backing array, even if only 
> numWords are in use



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to