Example #1
0
        public virtual void Test1()
        {
            const string bigbtreeTest1DbName = "bigbtree.test1.ndb";

            DeleteBase(bigbtreeTest1DbName);

            using (var odb = OdbFactory.Open(bigbtreeTest1DbName))
            {
                var    size = 10000;
                IBTree tree = new OdbBtreeSingle(50, new LazyOdbBtreePersister(((global::NDatabase.Odb)odb).GetStorageEngine()));
                for (var i = 0; i < size; i++)
                {
                    if (i % 1000 == 0)
                    {
                        Println(i);
                    }
                    tree.Insert(i + 1, "value " + (i + 1));
                }
                AssertEquals(size, tree.GetSize());
                IEnumerator iterator = new BTreeIteratorSingleValuePerKey <object>(tree, OrderByConstants.OrderByAsc);
                var         j        = 0;
                while (iterator.MoveNext())
                {
                    var o = iterator.Current;
                    // println(o);
                    j++;
                    if (j == size)
                    {
                        AssertEquals("value " + size, o);
                    }
                }
            }
        }
Example #2
0
        public virtual void Test2SameKeySingleBTree()
        {
            const string singlevaluebtreeTest1DbName = "singlevaluebtree.test1.ndb";

            DeleteBase(singlevaluebtreeTest1DbName);

            using (var odb = OdbFactory.Open(singlevaluebtreeTest1DbName))
            {
                var    size = 1000;
                IBTree tree = new OdbBtreeSingle(50, new LazyOdbBtreePersister(((global::NDatabase.Odb)odb).GetStorageEngine()));
                for (var i = 0; i < size; i++)
                {
                    if (i % 10000 == 0)
                    {
                        Println(i);
                    }
                    tree.Insert(i + 1, "value " + (i + 1));
                }
                try
                {
                    for (var i = 0; i < 10; i++)
                    {
                        if (i % 10000 == 0)
                        {
                            Println(i);
                        }
                        tree.Insert(100, "value " + (i + 1));
                        Fail("Single Value Btree should not accept duplcited key");
                    }
                }
                catch (DuplicatedKeyException ex)
                {
                    Console.WriteLine(ex.Message);
                    Assert.Pass();
                }
            }
        }