lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-3179) OpenBitSet.prevSetBit()
Date Fri, 24 Jun 2011 17:53:47 GMT

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

Uwe Schindler commented on LUCENE-3179:
---------------------------------------

The check for negative indexes must be done to make the following loop work (which is standard
to iterate backwards from "startBit" on all bits):

{code:java}
for (int i = bs.prevSetBit(startBit); i >= 0; i = bs.prevSetBit(i-1)) {
     // operate on index i here
}
{code}

This would fail with AIOOBE when i=0 on the last iteration (happens if 0th bit is set), because
bs.prevSetBit(i-1) has negative parameter. The exit condition is checked later, so -1 must
be allowed.

> OpenBitSet.prevSetBit()
> -----------------------
>
>                 Key: LUCENE-3179
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3179
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Paul Elschot
>            Priority: Minor
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3179-fix.patch, LUCENE-3179.patch, LUCENE-3179.patch, LUCENE-3179.patch,
TestBitUtil.java, TestOpenBitSet.patch
>
>
> Find a previous set bit in an OpenBitSet.
> Useful for parent testing in nested document query execution LUCENE-2454 .

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


Mime
View raw message