public DictQueueCacheCursor(IterableDict<string, DictBatchContainer> dict, string streamNamespace, Guid streamGuid)
 {
     _dict = dict;
     _curosr = _dict.GetCursor();
     _streamNamespace = streamNamespace;
     _streamGuid = streamGuid;
 }
예제 #2
0
 public void Setup()
 {
     _dict = new IterableDict <int, int>();
     for (int i = 0; i < _length; i++)
     {
         _dict.AddOrUpdate(i, i * 10);
     }
 }
예제 #3
0
        static void Main(string[] args)
        {
            _dict = new IterableDict<int, int>();
            for (int i = 0; i < len; i++)
            {
                _dict.AddOrUpdate(i, i);
            }

            var t1 = Task.Run(() => Manipulate());
            var t2 = Task.Run(() => Read());

            //Task.WaitAll(t1, t2);
            Console.ReadLine();
        }
예제 #4
0
        public void CreateFromExistingDict()
        {
            // create new normal dict
            var internalDict = new Dictionary <int, int>();
            // copy the iterable one into it
            var cursor = _dict.GetCursor();
            int i      = 0;

            while (cursor.MoveNext())
            {
                var v = cursor.GetCurrent();
                internalDict.AddOrUpdate(i, v);
                i++;
            }

            // create a new iterable from the normal dict
            var dict = new IterableDict <int, int>(internalDict);

            // read all from the new iterable
            var cursor1     = dict.GetCursor();
            var cursor1Read = new Dictionary <int, int>();
            IterableLinkedListNode <int> curr;

            while (cursor1.MoveNext())
            {
                curr = cursor1.GetCurrentNode();
                Assert.IsNotNull(curr?.Value);
                cursor1Read.AddOrUpdate(curr.Value, dict[curr.Value]);
            }

            // Check that we read the same from the new iterable as the normal dict
            foreach (var pair in internalDict)
            {
                Assert.IsTrue(cursor1Read.ContainsKey(pair.Key));
                Assert.AreEqual(cursor1Read[pair.Key], pair.Value);
            }
        }