org.apache.mahout.common
Class FastRandomSeedGenerator
java.lang.Object
org.apache.mahout.common.FastRandomSeedGenerator
- All Implemented Interfaces:
- org.uncommons.maths.random.SeedGenerator
public final class FastRandomSeedGenerator
- extends 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.
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 |
FastRandomSeedGenerator
public FastRandomSeedGenerator()
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-2012 The Apache Software Foundation. All Rights Reserved.