Re: svn commit: r1147535 - /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1147535 - /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java

Michael McCandless-2
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,  <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1147535 - /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java

Shai Erera
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 <[hidden email]> 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,  <[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

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

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1147535 - /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java

Michael McCandless-2
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 <[hidden email]> 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 <[hidden email]> 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,  <[hidden email]> 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: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

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

Reply | Threaded
Open this post in threaded view
|

RE: svn commit: r1147535 - /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java

Uwe Schindler
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: [hidden email]


> -----Original Message-----
> From: Michael McCandless [mailto:[hidden email]]
> Sent: Sunday, July 17, 2011 8:09 PM
> To: [hidden email]
> 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 <[hidden email]> 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
> <[hidden email]> 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,  <[hidden email]> 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: [hidden email] For
> >> additional commands, e-mail: [hidden email]
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email] For
> > additional commands, e-mail: [hidden email]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email] For additional
> commands, e-mail: [hidden email]


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

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1147535 - /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestFixedBitSet.java

Michael McCandless-2
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 <[hidden email]> 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: [hidden email]
>
>
>> -----Original Message-----
>> From: Michael McCandless [mailto:[hidden email]]
>> Sent: Sunday, July 17, 2011 8:09 PM
>> To: [hidden email]
>> 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 <[hidden email]> 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
>> <[hidden email]> 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,  <[hidden email]> 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: [hidden email] For
>> >> additional commands, e-mail: [hidden email]
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email] For
>> > additional commands, e-mail: [hidden email]
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email] For additional
>> commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

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