Example usage for org.apache.hadoop.util.hash MurmurHash getInstance

List of usage examples for org.apache.hadoop.util.hash MurmurHash getInstance

Introduction

In this page you can find the example usage for org.apache.hadoop.util.hash MurmurHash getInstance.

Prototype

public static Hash getInstance() 

Source Link

Usage

From source file:edu.snu.dolphin.ps.server.partitioned.PartitionedServerSideMsgHandler.java

License:Apache License

private int hash(final byte[] encodedKey) {
    return Math.abs(MurmurHash.getInstance().hash(encodedKey));
}

From source file:edu.snu.dolphin.ps.worker.partitioned.EncodedKey.java

License:Apache License

private int computeHash() {
    return Math.abs(MurmurHash.getInstance().hash(encoded));
}

From source file:org.apache.accumulo.examples.wikisearch.parser.QueryParser.java

License:Apache License

public void execute(String query) throws ParseException {
    reset();/*from   w  w  w .j  a  va 2 s  . c  om*/
    query = query.replaceAll("\\s+AND\\s+", " and ");
    query = query.replaceAll("\\s+OR\\s+", " or ");
    query = query.replaceAll("\\s+NOT\\s+", " not ");

    // Check to see if its in the cache
    Hash hash = MurmurHash.getInstance();
    this.hashVal = hash.hash(query.getBytes(), SEED);
    CacheEntry entry = null;
    synchronized (cache) {
        entry = (CacheEntry) cache.get(hashVal);
    }
    if (entry != null) {
        this.negatedTerms = entry.getNegatedTerms();
        this.andTerms = entry.getAndTerms();
        this.orTerms = entry.getOrTerms();
        this.literals = entry.getLiterals();
        this.terms = entry.getTerms();
        this.rootNode = entry.getRootNode();
        this.tree = entry.getTree();
    } else {
        Parser p = new Parser(new StringReader(";"));
        rootNode = p.parse(new StringReader(query), null);
        rootNode.childrenAccept(this, null);
        TreeBuilder builder = new TreeBuilder(rootNode);
        tree = builder.getRootNode();
        entry = new CacheEntry(this.negatedTerms, this.andTerms, this.orTerms, this.literals, this.terms,
                rootNode, tree);
        synchronized (cache) {
            cache.put(hashVal, entry);
        }
    }

}