Ejemplo n.º 1
0
        void PopulateIndex(ISortedCollection <Name, Person> list, int count)
        {
            Person firstPerson = null;

            foreach (var key in Tests.KeySeq(count))
            {
                Person p = new Person(key);
                if (null == firstPerson)
                {
                    firstPerson = p;
                }
                list.Add(p);
            }
            list.Add(firstPerson);
        }
Ejemplo n.º 2
0
        public InsertSearchIndex(IndexInfo indexInfo, ITable table, IEnumerable <long> rows)
            : base(indexInfo, table)
        {
            comparer = new IndexComparer(this);
            list     = new SortedCollection <IndexKey, long>();

            if (rows != null)
            {
                foreach (var row in rows)
                {
                    list.Add(row);
                }
            }
        }
Ejemplo n.º 3
0
        public void Run(TestConfig config)
        {
            int i;
            int count = config.Count;
            var res   = new TestIndex2Result();

            config.Result = res;
            var start = DateTime.Now;

            IDatabase db   = config.GetDatabase();
            Root      root = (Root)db.Root;

            Tests.Assert(root == null);
            root          = new Root();
            root.strIndex = db.CreateSortedCollection <string, Record>(new StrRecordComparator(), IndexType.Unique);
            root.intIndex = db.CreateSortedCollection <long, Record>(new IntRecordComparator(), IndexType.Unique);
            db.Root       = root;

            ISortedCollection <long, Record>   intIndex = root.intIndex;
            ISortedCollection <string, Record> strIndex = root.strIndex;

            foreach (var key in Tests.KeySeq(count))
            {
                Record rec = new Record();
                rec.intKey = key;
                rec.strKey = System.Convert.ToString(key);
                intIndex.Add(rec);
                strIndex.Add(rec);
            }
            db.Commit();
            res.InsertTime = DateTime.Now - start;

            start = System.DateTime.Now;

            foreach (var key in Tests.KeySeq(count))
            {
                Record rec1 = intIndex[key];
                Record rec2 = strIndex[Convert.ToString(key)];
            }
            res.IndexSearch = DateTime.Now - start;

            start = System.DateTime.Now;
            var k = Int64.MinValue;

            i = 0;
            foreach (Record rec in intIndex)
            {
                Tests.Assert(rec.intKey >= k);
                k  = rec.intKey;
                i += 1;
            }
            Tests.Assert(i == count);
            i = 0;
            String strKey = "";

            foreach (Record rec in strIndex)
            {
                Tests.Assert(rec.strKey.CompareTo(strKey) >= 0);
                strKey = rec.strKey;
                i     += 1;
            }
            Tests.Assert(i == count);
            res.IterationTime = DateTime.Now - start;

            start           = DateTime.Now;
            res.MemoryUsage = db.GetMemoryUsage().Values;

            start = System.DateTime.Now;
            foreach (var key in Tests.KeySeq(count))
            {
                Record rec = intIndex[key];
                intIndex.Remove(rec);
                strIndex.Remove(rec);
                rec.Deallocate();
            }
            res.RemoveTime = DateTime.Now - start;
            db.Close();
            //Tests.DumpMemoryUsage(res.TypeMemoryUsage);
        }