public virtual void TestMurmurHash3() { // Hashes computed using murmur3_32 from https://code.google.com/p/pyfasthash Assert.AreEqual(0xf6a5c420, (uint)StringHelper.Murmurhash3_x86_32(new BytesRef("foo"), 0)); Assert.AreEqual(0xcd018ef6, (uint)StringHelper.Murmurhash3_x86_32(new BytesRef("foo"), 16)); Assert.AreEqual(0x111e7435, (uint)StringHelper.Murmurhash3_x86_32(new BytesRef("You want weapons? We're in a library! Books! The best weapons in the world!"), 0)); Assert.AreEqual(0x2c628cd0, (uint)StringHelper.Murmurhash3_x86_32(new BytesRef("You want weapons? We're in a library! Books! The best weapons in the world!"), 3476)); }
/// <summary> /// Calculates the hash code as required by TermsHash during indexing. /// <p> this is currently implemented as MurmurHash3 (32 /// bit), using the seed from {@link /// StringHelper#GOOD_FAST_HASH_SEED}, but is subject to /// change from release to release. /// </summary> public override int GetHashCode() { return(StringHelper.Murmurhash3_x86_32(this, StringHelper.GOOD_FAST_HASH_SEED)); }
// TODO: maybe use long? But our keys are typically short... private static int DoHash(byte[] bytes, int offset, int length) { return StringHelper.Murmurhash3_x86_32(bytes, offset, length, StringHelper.GOOD_FAST_HASH_SEED); }
private static int DoHash(byte[] bytes, int offset, int length) { return(StringHelper.Murmurhash3_x86_32(bytes, offset, length, StringHelper.GoodFastHashSeed)); }