public void DuplicateDictionaryTest()
        {
            var dictionary = new DuplicateDetectorDictionary();
            var e1         = new Evidence();

            e1.Components = new List <int>();
            e1.Components.Add(10);
            Evidence existing = dictionary.TryAdd(1, e1);

            Assert.IsNull(existing);

            var e2 = new Evidence();

            e2.Components = new List <int>();
            e2.Components.Add(20);
            existing = dictionary.TryAdd(2, e2);
            Assert.IsNull(existing);

            var e3 = new Evidence();

            e3.Components = new List <int>();
            e3.Components.Add(30);
            existing = dictionary.TryAdd(2, e3);
            Assert.IsNull(existing);

            var e4 = new Evidence();

            e4.Components = new List <int>();
            e4.Components.Add(30);
            existing = dictionary.TryAdd(2, e4);
            Assert.IsNotNull(existing);
        }
Exemplo n.º 2
0
        private void TestDictionary(DuplicateDetectorDictionary _library, int baseModulus, int modulus)
        {
            A.Data.AsParallel().ForAll(kvp =>
            {
                var rollingTokenSet = new RollingTokenSet(new RollingHashCalculator <TokenInfo>(100, baseModulus, modulus));

                foreach (var list in kvp.Value)
                {
                    (int hash, Evidence evidence) = rollingTokenSet.Add(new TokenInfo(list));

                    if (rollingTokenSet.IsFull())
                    {
                        _ = _library.TryAdd(hash, evidence);
                    }
                }
            });
        }
        public void DuplicateDictionaryTest()
        {
            var dictionary = new DuplicateDetectorDictionary();
            var e1         = new Evidence(null, new List <int>()
            {
                10
            }, 10);

            Evidence existing = dictionary.TryAdd(1, e1);

            Assert.IsNull(existing);

            var e2 = new Evidence(null, new List <int>()
            {
                20
            }, 20);

            existing = dictionary.TryAdd(2, e2);
            Assert.IsNull(existing);

            var e3 = new Evidence(null, new List <int>()
            {
                30
            }, 30);

            existing = dictionary.TryAdd(2, e3);
            Assert.IsNull(existing);

            var e4 = new Evidence(null, new List <int>()
            {
                30
            }, 30);

            existing = dictionary.TryAdd(2, e4);
            Assert.IsNotNull(existing);
        }
Exemplo n.º 4
0
        public void OriginalHashParameters()
        {
            DuplicateDetectorDictionary _library = new DuplicateDetectorDictionary();

            TestDictionary(_library, 2048, 1723);
        }
Exemplo n.º 5
0
        public void BiggerPrimes()
        {
            DuplicateDetectorDictionary _library = new DuplicateDetectorDictionary();

            TestDictionary(_library, 227, 1000005);
        }