List of usage examples for org.apache.lucene.util StringHelper murmurhash3_x86_32
@SuppressWarnings("fallthrough") public static int murmurhash3_x86_32(byte[] data, int offset, int len, int seed)
From source file:org.elasticsearch.cluster.routing.Murmur3HashFunction.java
License:Apache License
@Override public int hash(String routing) { final byte[] bytesToHash = new byte[routing.length() * 2]; for (int i = 0; i < routing.length(); ++i) { final char c = routing.charAt(i); final byte b1 = (byte) c, b2 = (byte) (c >>> 8); assert ((b1 & 0xFF) | ((b2 & 0xFF) << 8)) == c; // no information loss bytesToHash[i * 2] = b1;/*w ww . j a va2s.com*/ bytesToHash[i * 2 + 1] = b2; } return StringHelper.murmurhash3_x86_32(bytesToHash, 0, bytesToHash.length, 0); }
From source file:org.elasticsearch.xpack.security.authc.BytesKey.java
License:Open Source License
public BytesKey(byte[] bytes) { this.bytes = bytes; this.hashCode = StringHelper.murmurhash3_x86_32(bytes, 0, bytes.length, StringHelper.GOOD_FAST_HASH_SEED); }