Beispiel #1
0
        public void TestInsertWithIndex3()
        {
            var baseName = GetBaseName();
            // LogUtil.logOn(LazyOdbBtreePersister.LOG_ID, true);
            DeleteBase(baseName);
            var odb = Open(baseName);

            // base.store(new IndexedObject());
            var clazz = odb.IndexManagerFor<IndexedObject>();
            var indexFields = new[] {"name"};
            clazz.AddUniqueIndexOn("index1", indexFields);
            odb.Close();
            odb = Open(baseName);
            var size = 1300;
            var commitInterval = 10;
            var start0 = OdbTime.GetCurrentTimeInMs();
            var engine = ((global::NDatabase.Odb)odb).GetStorageEngine();
            for (var i = 0; i < size; i++)
            {
                var io1 = new IndexedObject("olivier" + (i + 1), 15 + size, new DateTime());
                odb.Store(io1);
                if (i % commitInterval == 0)
                {
                    odb.Commit();
                    odb.Close();
                    odb = Open(baseName);
                    engine = ((global::NDatabase.Odb)odb).GetStorageEngine();
                }
                if (io1.GetName().Equals("olivier" + size))
                    Println("Ola chico");
            }
            engine = ((global::NDatabase.Odb)odb).GetStorageEngine();
            // println(new
            // BTreeDisplay().build(engine.getSession(true).getMetaModel().getClassInfo(IndexedObject.class.Name,
            // true).getIndex(0).getBTree(), true));
            odb.Close();
            var end0 = OdbTime.GetCurrentTimeInMs();

            // ObjectWriter.getNbNormalUpdates());
            Console.WriteLine("inserting time with index=" + (end0 - start0));
            odb = Open(baseName);

            IQuery q = odb.Query<IndexedObject>();
            q.Descend("name").Constrain((object) ("olivier" + size)).Equal();
            var start = OdbTime.GetCurrentTimeInMs();
            var objects = q.Execute<IndexedObject>(false);
            var end = OdbTime.GetCurrentTimeInMs();
            try
            {
                AssertEquals(1, objects.Count);
                var io2 = objects.GetFirst();
                AssertEquals("olivier" + size, io2.GetName());
                AssertEquals(15 + size, io2.GetDuration());
                var duration = end - start;
                Println("duration=" + duration);

                if (testPerformance)
                {
                    if (duration > 2)
                        Fail("Time of search in index is greater than 2ms : " + duration);
                }
            }
            finally
            {
                odb.Close();
                DeleteBase(baseName);
            }
        }
Beispiel #2
0
        public void TestInsertWithIndex3Part1()
        {
            var baseName = "index.ndb";
            // LogUtil.logOn(LazyOdbBtreePersister.LOG_ID, true);
            DeleteBase(baseName);
            var @base = Open(baseName);

            // base.store(new IndexedObject());
            var clazz = @base.IndexManagerFor<IndexedObject>();
            var indexFields = new[] {"name"};
            clazz.AddUniqueIndexOn("index1", indexFields);
            @base.Close();
            @base = Open(baseName);
            var size = 1300;
            var commitInterval = 10;
            var start0 = OdbTime.GetCurrentTimeInMs();
            var engine = ((global::NDatabase.Odb)@base).GetStorageEngine();
            for (var i = 0; i < size; i++)
            {
                var io1 = new IndexedObject("olivier" + (i + 1), 15 + size, new DateTime());
                @base.Store(io1);
                if (i % commitInterval == 0)
                {
                    @base.Commit();
                    @base.Close();
                    @base = Open(baseName);
                    engine = ((global::NDatabase.Odb)@base).GetStorageEngine();
                }
                if (io1.GetName().Equals("olivier" + size))
                    Println("Ola chico");
            }
            engine = ((global::NDatabase.Odb)@base).GetStorageEngine();
            // println(new
            // BTreeDisplay().build(engine.getSession(true).getMetaModel().getClassInfo(IndexedObject.class.Name,
            // true).getIndex(0).getBTree(), true));
            @base.Close();
            var end0 = OdbTime.GetCurrentTimeInMs();
        }