com.twitter.common.util
Class Sampler

java.lang.Object
  extended by com.twitter.common.util.Sampler

public class Sampler
extends Object

A sampler that implements logic for fractional random selection.


Constructor Summary
Sampler(float selectPercent)
          Creates a new sampler using the default system Random.
Sampler(float selectPercent, Random rand)
          Creates a new sampler using the provided Random.
 
Method Summary
 boolean select()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sampler

public Sampler(float selectPercent)
Creates a new sampler using the default system Random.

Parameters:
selectPercent - Percentage to randomly select, must be between 0 and 100 (inclusive).

Sampler

public Sampler(float selectPercent,
               Random rand)
Creates a new sampler using the provided Random.

Parameters:
selectPercent - Percentage to randoml select, must be between 0 and 100 (inclusive).
rand - The random utility to use for generating random numbers.
Method Detail

select

public boolean select()