28 public long val1 {
get; set; }
29 public long val2 {
get; set; }
33 private static ulong fmix64( UInt64 k )
36 k *= 0xff51afd7ed558ccdL;
38 k *= 0xc4ceb9fe1a85ec53L;
50 private static ulong RotateLeft(
this ulong original,
int bits )
52 return ( original << bits ) | ( original >> ( 64 - bits ) );
63 ulong h1 = (ulong) (seed & 0x00000000FFFFFFFFL);
64 ulong h2 = (ulong) (seed & 0x00000000FFFFFFFFL);
66 const ulong c1 = 0x87c37b91114253d5L;
67 const ulong c2 = 0x4cf5ad432745937fL;
69 uint roundedEnd = offset + (len & 0xFFFFFFF0);
72 for (
int i = (
int)offset; i < roundedEnd; i += 16 )
74 ulong key1 = BitConverter.ToUInt64( key, i );
75 ulong key2 = BitConverter.ToUInt64( key, (i + 8) );
77 key1 *= c1; key1 = key1.RotateLeft( 31 ); key1 *= c2; h1 ^= key1;
78 h1 = h1.RotateLeft( 27 ); h1 += h2; h1 = h1 * 5 + 0x52dce729;
79 key2 *= c2; key2 = key2.RotateLeft( 33 ); key2 *= c1; h2 ^= key2;
80 h2 = h2.RotateLeft( 31 ); h2 += h1; h2 = h2 * 5 + 0x38495ab5;
90 k2 = ( ulong ) ( key[roundedEnd + 14] & 0xffL ) << 48;
93 k2 |= ( ulong ) ( key[roundedEnd + 13] & 0xffL ) << 40;
96 k2 |= ( ulong ) ( key[roundedEnd + 12] & 0xffL ) << 32;
99 k2 |= ( ulong ) ( key[roundedEnd + 11] & 0xffL ) << 24;
102 k2 |= ( ulong ) ( key[roundedEnd + 10] & 0xffL ) << 16;
105 k2 |= ( ulong ) ( key[roundedEnd + 9] & 0xffL ) << 8;
108 k2 |= ( ulong ) ( key[roundedEnd + 8] & 0xffL );
109 k2 *= c2; k2 = k2.RotateLeft( 33 ); k2 *= c1; h2 ^= k2;
114 k1 = ( ( ulong ) key[roundedEnd + 7] ) << 56;
117 k1 |= ( ulong ) ( key[roundedEnd + 6] & 0xffL ) << 48;
120 k1 |= ( ulong ) ( key[roundedEnd + 5] & 0xffL ) << 40;
123 k1 |= ( ulong ) ( key[roundedEnd + 4] & 0xffL ) << 32;
126 k1 |= ( ulong ) ( key[roundedEnd + 3] & 0xffL ) << 24;
129 k1 |= ( ulong ) ( key[roundedEnd + 2] & 0xffL ) << 16;
132 k1 |= ( ulong ) ( key[roundedEnd + 1] & 0xffL ) << 8;
135 k1 |= ( ulong ) ( key[roundedEnd] & 0xffL );
136 k1 *= c1; k1 = k1.RotateLeft( 31 ); k1 *= c2; h1 ^= k1;
157 output.val1 = (long) h1;
158 output.val2 = (long) h2;
static void murmurhash3_x64_128(byte[] key, uint offset, uint len, int seed, out LongPair output)
Returns the MurmurHash3_x64_128 hash, placing the result in output