Exemplo n.º 1
0
        public void VerifyMurmurHash()
        {
            var hFunc = new MurmurHash3_x86_32();
            var x = VerificationTest(hFunc, 32, 0xB0F57EE3, true); // For MurmurHash3_x86_32
            Assert.IsTrue(x);

            var hFunc128 = new MurmurHash3_x64_128();
            var y = VerificationTest(hFunc128, 128, 0x6384BA69, true); // For MurmurHash3_x64_128
            Assert.IsTrue(y);
        }
Exemplo n.º 2
0
        public static IEnumerable<KeyValuePair<string, string>> Gen(int size, int changedPercent)
        {
            var hFunc = new MurmurHash3_x64_128();
            var modifiedPercent = changedPercent / 2;
            var addedPercent = changedPercent / 2;
            var modifiedCount = modifiedPercent * size / 100;
            var addedCount = addedPercent * size / 100;

            // Modified
            for (var i = 0; i < modifiedCount; ++i)
            {
                var str = BitConverter.ToString(hFunc.ComputeHash(BitConverter.GetBytes(-i - 1)));
                var valStr = str + str;
                yield return new KeyValuePair<string, string>(i.ToString(), valStr);
            }

            // Original + added
            for (var i = modifiedCount; i < size + addedCount; ++i)
            {
                var str = BitConverter.ToString(hFunc.ComputeHash(BitConverter.GetBytes(i)));
                var valStr = str + str;
                yield return new KeyValuePair<string, string>(i.ToString(), valStr);
            }
        }