org.apache.mahout.common
Class FastRandomSeedGenerator

java.lang.Object
  extended by org.apache.mahout.common.FastRandomSeedGenerator
All Implemented Interfaces:
org.uncommons.maths.random.SeedGenerator

public class FastRandomSeedGenerator
extends java.lang.Object
implements org.uncommons.maths.random.SeedGenerator

Implements an uncommons math compatible generator that avoids /dev/random's tendency to block due to entropy underflow.


Constructor Summary
FastRandomSeedGenerator()
           
 
Method Summary
 byte[] generateSeed(int length)
          Generate a seed value for a random number generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastRandomSeedGenerator

public FastRandomSeedGenerator()
Method Detail

generateSeed

public byte[] generateSeed(int length)
                    throws org.uncommons.maths.random.SeedException
Generate a seed value for a random number generator. Try the /dev/urandom generator first, and then fall back to SecureRandomSeedGenerator to guarantee a result. On platforms with /dev/random, /dev/urandom should exist and thus be fast and pretty good. On platforms without /dev/random, the fallback strategies should also be pretty fast.

Specified by:
generateSeed in interface org.uncommons.maths.random.SeedGenerator
Parameters:
length - The length of the seed to generate (in bytes).
Returns:
A byte array containing the seed data.
Throws:
org.uncommons.maths.random.SeedException - If a seed cannot be generated for any reason.


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.