lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adrien Grand (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-4148) _TestUtil should be able to generate random longs
Date Fri, 15 Jun 2012 15:18:42 GMT

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

Adrien Grand commented on LUCENE-4148:
--------------------------------------

bq. Try RandomInts from randomizedtesting

Thanks, it fixes the problem for large range of ints, but I would also like to be able to
generate random longs (> Integer.MAX_VALUE) in a fixed range. For {{PackedInts}}, I always
need longs between 0 and a power of 2, but I thought it would be more useful to add a general-purpose
{{long nextLong(Random, long, long)}} to {{_TestUtil}}.

Since {{Random.nextLong(long)}} doesn't exist, it would be tempting to implement it by ourselves
by using the same logic as {{Random.nextInt(int)}}, but I am afraid there would be copyright
issues, so we should probably do it otherwise (?).

By the way, the code of {{randomIntBetween}} makes me curious, are all values as likely when
the range of values is {{>= Integer.MAX_VALUE}} (ie. when the else block gets executed)?
                
> _TestUtil should be able to generate random longs
> -------------------------------------------------
>
>                 Key: LUCENE-4148
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4148
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: general/test
>            Reporter: Adrien Grand
>            Priority: Trivial
>
> 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
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