Java 类org.apache.hadoop.util.hash.MurmurHash 实例源码

项目:accumulo-wikisearch    文件:QueryParser.java   
public void execute(String query) throws ParseException {
  reset();
  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);
    }
  }

}
项目:accumulo-recipes    文件:QueryParser.java   
public void execute(String query) throws ParseException {
    reset();
    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);
        }
    }

}
项目:cruise    文件:EncodedKey.java   
private int computeHash(final byte[] encodedKey) {
  return Math.abs(MurmurHash.getInstance().hash(encodedKey));
}