/** * Returns the 64 most significant bits of the Murmur128 hash of the provided value */ public static long hash64(Slice data) { return Murmur3Hash128.hash64(data); }
public static Slice hash(Slice data, int offset, int length) { return hash(DEFAULT_SEED, data, offset, length); }
@Test(invocationCount = 100) public void test64ReturnsMsb() throws Exception { byte[] data = randomBytes(ThreadLocalRandom.current().nextInt(200)); long expected = Murmur3Hash128.hash(Slices.wrappedBuffer(data)).getLong(0); long actual = Murmur3Hash128.hash64(Slices.wrappedBuffer(data)); assertEquals(actual, expected); }
@Test(invocationCount = 100) public void testLessThan16Bytes64() throws Exception { byte[] data = randomBytes(ThreadLocalRandom.current().nextInt(16)); long expected = Murmur3Hash128.hash(Slices.wrappedBuffer(data)).getLong(0); long actual = Murmur3Hash128.hash64(Slices.wrappedBuffer(data)); assertEquals(actual, expected); }
/** * Special-purpose version for hashing a single long value. Value is treated as little-endian */ public static long hash64(long value) { return Murmur3Hash128.hash64(value); } }
@Test(invocationCount = 100) public void test64ReturnsMsb() throws Exception { byte[] data = randomBytes(ThreadLocalRandom.current().nextInt(200)); long expected = Murmur3Hash128.hash(Slices.wrappedBuffer(data)).getLong(0); long actual = Murmur3Hash128.hash64(Slices.wrappedBuffer(data)); assertEquals(actual, expected); }
public static Slice hash(Slice data, int offset, int length) { return hash(DEFAULT_SEED, data, offset, length); }
/** * Special-purpose version for hashing a single long value. Value is treated as little-endian */ public static long hash64(long value) { return Murmur3Hash128.hash64(value); } }
@Test(invocationCount = 100) public void testLessThan16Bytes64() throws Exception { byte[] data = randomBytes(ThreadLocalRandom.current().nextInt(16)); long expected = Murmur3Hash128.hash(Slices.wrappedBuffer(data)).getLong(0); long actual = Murmur3Hash128.hash64(Slices.wrappedBuffer(data)); assertEquals(actual, expected); }
public static Slice hash(long seed, Slice data, int offset, int length) { return Murmur3Hash128.hash(seed, data, offset, length); }
public static long hash64(Slice data, int offset, int length) { return hash64(DEFAULT_SEED, data, offset, length); }
public static Slice hash(Slice data) { return Murmur3Hash128.hash(data); }
/** * Returns the 64 most significant bits of the Murmur128 hash of the provided value */ public static long hash64(Slice data) { return Murmur3Hash128.hash64(data); }
@Test(invocationCount = 100) public void testNonDefaultSeed64() throws Exception { byte[] data = randomBytes(131); int seed = 123456789; long expected = Murmur3Hash128.hash(seed, Slices.wrappedBuffer(data), 0, data.length).getLong(0); long actual = Murmur3Hash128.hash64(seed, Slices.wrappedBuffer(data), 0, data.length); assertEquals(actual, expected); }
public static Slice hash(Slice data) { return Murmur3Hash128.hash(data); }