Example usage for org.apache.mahout.math MurmurHash hash

List of usage examples for org.apache.mahout.math MurmurHash hash

Introduction

In this page you can find the example usage for org.apache.mahout.math MurmurHash hash.

Prototype

public static int hash(ByteBuffer buf, int seed) 

Source Link

Document

Hashes the bytes in a buffer from the current position to the limit.

Usage

From source file:io.seldon.recommendation.VariationTestingClientStrategy.java

License:Apache License

public ClientStrategy sample(String userId) {
    Integer hash = MurmurHash.hash(userId.getBytes(), HASH_SEED);
    int sample = Math.abs(hash % 100);
    BigDecimal sampleDec = BigDecimal.valueOf(sample).divide(BigDecimal.valueOf(100));
    for (Range range : strategyMap.keySet()) {
        if (range.containsNumber(sampleDec)) {
            return strategyMap.get(range);
        }/*from ww  w . ja  v  a  2  s. c o m*/
    }
    return null;
}