lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adrien Grand (JIRA)" <>
Subject [jira] [Updated] (LUCENE-4148) _TestUtil should be able to generate random longs
Date Mon, 18 Jun 2012 13:50:43 GMT


Adrien Grand updated LUCENE-4148:

    Attachment: LUCENE-4148.patch

Here is a patch proposition:
 * {{_TestUtil.nextInt}} forwards calls to {{RandomInts.randomIntBetween}}, as Robert suggested,
 * A new {{_TestUtil.nextLong}} uses {{Random.nextInt(int)}} when the range does not exceed
{{Integer.MAX_VALUE}} and scales {{Double.nextDouble}} into the expected range of values otherwise
using {{BigDecimal}} arithmetic.

I also updated a few tests to use this new method (especially a call to {{Math.abs(random.nextLong())}}
in {{TestIndexInput}}, which is buggy since {{random.nextLong()}} might return Long.MIN_VALUE
whose absolute value cannot be represented by a long).
> _TestUtil should be able to generate random longs
> -------------------------------------------------
>                 Key: LUCENE-4148
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: general/test
>            Reporter: Adrien Grand
>            Priority: Trivial
>         Attachments: LUCENE-4148.patch
> It would be helpful in TestPackedInts at least, in order to generate random values (as
a workaround, we currently generate a random int between 0 and {{min(Integer.MAX_VALUE, PackedInts.maxValue(bitsPerValue)}}).
Moreover, it would help to fix {{nextInt}} for large ranges (calling {{nextInt(random, -10,
Integer.MAX_VALUE)}} or even {{nextInt(random, 0, Integer.MAX_VALUE)}} currently fails because
the range of values is {{> Integer.MAX_VALUE}}.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message