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

Lance Norskog commented on MAHOUT-687:
--------------------------------------

bq. Is this still useful? I am like Sean and have lost the thrust of the patch.

I'm still working on it.

Ted, you mentioned wanting a MurmurHash Random class. Is this what you 
envisioned? (It is not finished code; see below).

{code}
public class MurmurHashRandom extends Random {
  private long murmurSeed;
  private final ByteBuffer buf;
  
  public MurmurHashRandom() {
    this(0);
  }

  public MurmurHashRandom(int seed) {
    SeedGenerator gen = new FastRandomSeedGenerator();
    byte[] bits = RandomUtils.longSeedtoBytes(gen.generateSeed());
    buf = ByteBuffer.wrap(bits);
    this.murmurSeed = MurmurHash.hash64A(bits, seed);
  }
  
  @Override
  public long nextLong() {
    long oldSeed = murmurSeed;
    murmurSeed = MurmurHash.hash64A(buf, (int) murmurSeed);
    return oldSeed;
  }

{code}

It is coded against my patch, so is only here for study purposes.It's coded 
against the MurmurHash class in encoders.encoders.MurmurHash works in ints, not 
longs, so types are a bit confused in this demo code.

> Random generator objects- slight refactor
> -----------------------------------------
>
>                 Key: MAHOUT-687
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-687
>             Project: Mahout
>          Issue Type: Improvement
>            Reporter: Lance Norskog
>            Priority: Minor
>         Attachments: MAHOUT-687.patch, MAHOUT-687.patch
>
>
> Problems:
> * The uncommons RepeatableRNG classes are the basis of RandomUtils.
> ** These classes cheerfully ignore setSeed.
> * Some people in the project want to move off Uncommons anyway.
> This patch uses the org.apache.commons.math.random.RandomGenerator classes 
> instead of org.apache.uncommons.maths.RepeatableRNG classes.
> .

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to