Grokbase Groups Lucene dev July 2011
FAQ
Is it just the test that has a problem w/ numBits == 0?

I think it should be fine to create a 0-length bitset. It's just that
you can't then use it :)

Mike McCandless

http://blog.mikemccandless.com
On Sun, Jul 17, 2011 at 2:01 AM, wrote:
Author: shaie
Date: Sun Jul 17 06:01:02 2011
New Revision: 1147535

URL: http://svn.apache.org/viewvc?rev=1147535&view=rev
Log:
random.nextInt does not take '0' as a valid argument, so ensure numBits is never 0

Modified:
lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java?rev=1147535&r1=1147534&r2=1147535&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java Sun Jul 17 06:01:02 2011
@@ -197,7 +197,7 @@ public class TestFixedBitSet extends Luc
*/

public void testEquals() {
-    final int numBits = random.nextInt(2000);
+    final int numBits = random.nextInt(2000) + 1 /* numBits cannot be 0 */;
FixedBitSet b1 = new FixedBitSet(numBits);
FixedBitSet b2 = new FixedBitSet(numBits);
assertTrue(b1.equals(b2));

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

Search Discussions

  • Shai Erera at Jul 17, 2011 at 5:23 pm
    You mean whether FixedBitSet should throw exc if numBits=0? I don't
    think it's very likely that someone will use it?

    But you're right - it's not invalid to create a 0-length bitset, even
    if not very useful.

    Shai
    On Sunday, July 17, 2011, Michael McCandless wrote:
    Is it just the test that has a problem w/ numBits == 0?

    I think it should be fine to create a 0-length bitset.  It's just that
    you can't then use it :)

    Mike McCandless

    http://blog.mikemccandless.com
    On Sun, Jul 17, 2011 at 2:01 AM,  wrote:
    Author: shaie
    Date: Sun Jul 17 06:01:02 2011
    New Revision: 1147535

    URL: http://svn.apache.org/viewvc?rev=1147535&view=rev
    Log:
    random.nextInt does not take '0' as a valid argument, so ensure numBits is never 0

    Modified:
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java

    Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java
    URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java?rev=1147535&r1=1147534&r2=1147535&view=diff
    ==============================================================================
    --- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java (original)
    +++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java Sun Jul 17 06:01:02 2011
    @@ -197,7 +197,7 @@ public class TestFixedBitSet extends Luc
    */

    public void testEquals() {
    -    final int numBits = random.nextInt(2000);
    +    final int numBits = random.nextInt(2000) + 1 /* numBits cannot be 0 */;
    FixedBitSet b1 = new FixedBitSet(numBits);
    FixedBitSet b2 = new FixedBitSet(numBits);
    assertTrue(b1.equals(b2));

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
    For additional commands, e-mail: dev-help@lucene.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
    For additional commands, e-mail: dev-help@lucene.apache.org
  • Michael McCandless at Jul 17, 2011 at 6:09 pm
    OK so this was a test-only limitation (good) not a problem w/ FixedBitSet.

    I'll add an additional test case to explicitly test the 0 case.

    Mike McCandless

    http://blog.mikemccandless.com
    On Sun, Jul 17, 2011 at 1:22 PM, Shai Erera wrote:
    You mean whether FixedBitSet should throw exc if numBits=0? I don't
    think it's very likely that someone will use it?

    But you're right - it's not invalid to create a 0-length bitset, even
    if not very useful.

    Shai
    On Sunday, July 17, 2011, Michael McCandless wrote:
    Is it just the test that has a problem w/ numBits == 0?

    I think it should be fine to create a 0-length bitset.  It's just that
    you can't then use it :)

    Mike McCandless

    http://blog.mikemccandless.com
    On Sun, Jul 17, 2011 at 2:01 AM,  wrote:
    Author: shaie
    Date: Sun Jul 17 06:01:02 2011
    New Revision: 1147535

    URL: http://svn.apache.org/viewvc?rev=1147535&view=rev
    Log:
    random.nextInt does not take '0' as a valid argument, so ensure numBits is never 0

    Modified:
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java

    Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java
    URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java?rev=1147535&r1=1147534&r2=1147535&view=diff
    ==============================================================================
    --- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java (original)
    +++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java Sun Jul 17 06:01:02 2011
    @@ -197,7 +197,7 @@ public class TestFixedBitSet extends Luc
    */

    public void testEquals() {
    -    final int numBits = random.nextInt(2000);
    +    final int numBits = random.nextInt(2000) + 1 /* numBits cannot be 0 */;
    FixedBitSet b1 = new FixedBitSet(numBits);
    FixedBitSet b2 = new FixedBitSet(numBits);
    assertTrue(b1.equals(b2));

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
    For additional commands, e-mail: dev-help@lucene.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
    For additional commands, e-mail: dev-help@lucene.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
    For additional commands, e-mail: dev-help@lucene.apache.org
  • Uwe Schindler at Jul 17, 2011 at 6:16 pm
    We should in all cases allow 0-length bitsets. Think of a Filter that gets
    invoked with a 0-document segment (empty index). Maybe that’s not possible,
    but without allowing 0-length, it would crash.

    -----
    Uwe Schindler
    H.-H.-Meier-Allee 63, D-28213 Bremen
    http://www.thetaphi.de
    eMail: uwe@thetaphi.de

    -----Original Message-----
    From: Michael McCandless
    Sent: Sunday, July 17, 2011 8:09 PM
    To: dev@lucene.apache.org
    Subject: Re: svn commit: r1147535 -
    /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/T
    estFixedBitSet.java

    OK so this was a test-only limitation (good) not a problem w/ FixedBitSet.

    I'll add an additional test case to explicitly test the 0 case.

    Mike McCandless

    http://blog.mikemccandless.com
    On Sun, Jul 17, 2011 at 1:22 PM, Shai Erera wrote:
    You mean whether FixedBitSet should throw exc if numBits=0? I don't
    think it's very likely that someone will use it?

    But you're right - it's not invalid to create a 0-length bitset, even
    if not very useful.

    Shai

    On Sunday, July 17, 2011, Michael McCandless
    wrote:
    Is it just the test that has a problem w/ numBits == 0?

    I think it should be fine to create a 0-length bitset.  It's just
    that you can't then use it :)

    Mike McCandless

    http://blog.mikemccandless.com
    On Sun, Jul 17, 2011 at 2:01 AM,  wrote:
    Author: shaie
    Date: Sun Jul 17 06:01:02 2011
    New Revision: 1147535

    URL: http://svn.apache.org/viewvc?rev=1147535&view=rev
    Log:
    random.nextInt does not take '0' as a valid argument, so ensure
    numBits is never 0

    Modified:
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util
    /TestFixedBitSet.java

    Modified:
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util
    /TestFixedBitSet.java
    URL:
    http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/sr
    c/test/org/apache/lucene/util/TestFixedBitSet.java?rev=1147535&r1=11
    47534&r2=1147535&view=diff
    ==========================================================
    ==========
    ==========
    ---
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util
    /TestFixedBitSet.java (original)
    +++
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/
    +++ util/TestFixedBitSet.java Sun Jul 17 06:01:02 2011
    @@ -197,7 +197,7 @@ public class TestFixedBitSet extends Luc
    */

    public void testEquals() {
    -    final int numBits = random.nextInt(2000);
    +    final int numBits = random.nextInt(2000) + 1 /* numBits cannot
    + be 0 */;
    FixedBitSet b1 = new FixedBitSet(numBits);
    FixedBitSet b2 = new FixedBitSet(numBits);
    assertTrue(b1.equals(b2));

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

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
    For additional commands, e-mail: dev-help@lucene.apache.org
  • Michael McCandless at Jul 17, 2011 at 6:18 pm
    I agree, and we do!

    I just committed an explicit test case to make sure (instead of
    relying on random(2000) returning 0).

    Mike McCandless

    http://blog.mikemccandless.com
    On Sun, Jul 17, 2011 at 2:16 PM, Uwe Schindler wrote:
    We should in all cases allow 0-length bitsets. Think of a Filter that gets
    invoked with a 0-document segment (empty index). Maybe that’s not possible,
    but without allowing 0-length, it would crash.

    -----
    Uwe Schindler
    H.-H.-Meier-Allee 63, D-28213 Bremen
    http://www.thetaphi.de
    eMail: uwe@thetaphi.de

    -----Original Message-----
    From: Michael McCandless
    Sent: Sunday, July 17, 2011 8:09 PM
    To: dev@lucene.apache.org
    Subject: Re: svn commit: r1147535 -
    /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/T
    estFixedBitSet.java

    OK so this was a test-only limitation (good) not a problem w/ FixedBitSet.

    I'll add an additional test case to explicitly test the 0 case.

    Mike McCandless

    http://blog.mikemccandless.com
    On Sun, Jul 17, 2011 at 1:22 PM, Shai Erera wrote:
    You mean whether FixedBitSet should throw exc if numBits=0? I don't
    think it's very likely that someone will use it?

    But you're right - it's not invalid to create a 0-length bitset, even
    if not very useful.

    Shai

    On Sunday, July 17, 2011, Michael McCandless
    wrote:
    Is it just the test that has a problem w/ numBits == 0?

    I think it should be fine to create a 0-length bitset.  It's just
    that you can't then use it :)

    Mike McCandless

    http://blog.mikemccandless.com
    On Sun, Jul 17, 2011 at 2:01 AM,  wrote:
    Author: shaie
    Date: Sun Jul 17 06:01:02 2011
    New Revision: 1147535

    URL: http://svn.apache.org/viewvc?rev=1147535&view=rev
    Log:
    random.nextInt does not take '0' as a valid argument, so ensure
    numBits is never 0

    Modified:
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util
    /TestFixedBitSet.java

    Modified:
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util
    /TestFixedBitSet.java
    URL:
    http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/sr
    c/test/org/apache/lucene/util/TestFixedBitSet.java?rev=1147535&r1=11
    47534&r2=1147535&view=diff
    ==========================================================
    ==========
    ==========
    ---
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util
    /TestFixedBitSet.java (original)
    +++
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/
    +++ util/TestFixedBitSet.java Sun Jul 17 06:01:02 2011
    @@ -197,7 +197,7 @@ public class TestFixedBitSet extends Luc
    */

    public void testEquals() {
    -    final int numBits = random.nextInt(2000);
    +    final int numBits = random.nextInt(2000) + 1 /* numBits cannot
    + be 0 */;
    FixedBitSet b1 = new FixedBitSet(numBits);
    FixedBitSet b2 = new FixedBitSet(numBits);
    assertTrue(b1.equals(b2));

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

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categorieslucene
postedJul 17, '11 at 12:15p
activeJul 17, '11 at 6:18p
posts5
users3
websitelucene.apache.org

People

Translate

site design / logo © 2021 Grokbase