Esempio n. 1
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test1()
        {
            Println("************START OF TEST1***************");
            string baseName = GetBaseName();

            DeleteBase("index-object");
            NeoDatis.Odb.ODB odb    = Open("index-object");
            string[]         fields = new string[] { "object" };
            odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject2)).AddUniqueIndexOn
                ("index1", fields, true);
            NeoDatis.Odb.Test.Index.IndexedObject2 o1 = new NeoDatis.Odb.Test.Index.IndexedObject2
                                                            ("Object1", new NeoDatis.Odb.Test.Index.IndexedObject("Inner Object 1", 10, new
                                                                                                                  System.DateTime()));
            odb.Store(o1);
            odb.Close();
            odb = Open("index-object");
            // First get the object used to index
            NeoDatis.Odb.Objects objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.Index.IndexedObject
                                                                 ));
            NeoDatis.Odb.Test.Index.IndexedObject io = (NeoDatis.Odb.Test.Index.IndexedObject
                                                        )objects.GetFirst();
            NeoDatis.Odb.Core.Query.IQuery q = odb.CriteriaQuery(typeof(NeoDatis.Odb.Test.Index.IndexedObject2
                                                                        ), NeoDatis.Odb.Core.Query.Criteria.Where.Equal("object", io));
            objects = odb.GetObjects(q);
            NeoDatis.Odb.Test.Index.IndexedObject2 o2 = (NeoDatis.Odb.Test.Index.IndexedObject2
                                                         )objects.GetFirst();
            odb.Close();
            AssertEquals(o1.GetName(), o2.GetName());
            Println(q.GetExecutionPlan().GetDetails());
            AssertFalse(q.GetExecutionPlan().GetDetails().IndexOf("index1") == -1);
            DeleteBase("index-object");
            Println("************END OF TEST1***************");
        }
        /// <summary>Test the creation of an index after having created objects.</summary>
        /// <remarks>
        /// Test the creation of an index after having created objects. In this case
        /// ODB should creates the index and update it with already existing objects
        /// </remarks>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test1Object()
        {
            string OdbFileName = "index2";

            NeoDatis.Odb.ODB odb = null;
            try
            {
                DeleteBase(OdbFileName);
                odb = Open(OdbFileName);
                NeoDatis.Odb.Test.Index.IndexedObject io = new NeoDatis.Odb.Test.Index.IndexedObject
                                                               ("name", 5, new System.DateTime());
                odb.Store(io);
                odb.Close();
                odb = Open(OdbFileName);
                string[] names = new string[] { "name" };
                odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject)).AddUniqueIndexOn
                    ("index1", names, true);
                NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                                  (typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
                                                                  .Equal("name", "name")), true);
                AssertEquals(1, objects.Count);
            }
            catch (System.Exception e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
            finally
            {
                if (odb != null)
                {
                    odb.Close();
                }
            }
        }
		/// <summary>Test the creation of an index after having created objects.</summary>
		/// <remarks>
		/// Test the creation of an index after having created objects. In this case
		/// ODB should creates the index and update it with already existing objects
		/// </remarks>
		/// <exception cref="System.Exception">System.Exception</exception>
		public virtual void Test1Object()
		{
			string OdbFileName = "index2";
			NeoDatis.Odb.ODB odb = null;
			try
			{
				DeleteBase(OdbFileName);
				odb = Open(OdbFileName);
				NeoDatis.Odb.Test.Index.IndexedObject io = new NeoDatis.Odb.Test.Index.IndexedObject
					("name", 5, new System.DateTime());
				odb.Store(io);
				odb.Close();
				odb = Open(OdbFileName);
				string[] names = new string[] { "name" };
				odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject)).AddUniqueIndexOn
					("index1", names, true);
				NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
					(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
					.Equal("name", "name")), true);
				AssertEquals(1, objects.Count);
			}
			catch (System.Exception e)
			{
				Sharpen.Runtime.PrintStackTrace(e);
			}
			finally
			{
				if (odb != null)
				{
					odb.Close();
				}
			}
		}
Esempio n. 4
0
        public virtual void TestInsertWithIndex()
		{
			string baseName = GetBaseName();
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields = new string[] { "name", "duration" };
			clazz.AddUniqueIndexOn("index1", indexFields, true);
			@base.Close();
			@base = Open(baseName);
			NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
				("olivier", 15, new System.DateTime());
			@base.Store(io1);
			@base.Close();
			@base = Open(baseName);
			NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
				.IsNotNull("name"));
			NeoDatis.Odb.Objects objects = @base.GetObjects(q, true);
			@base.Close();
			AssertEquals(1, objects.Count);
			NeoDatis.Odb.Test.Index.IndexedObject io2 = (NeoDatis.Odb.Test.Index.IndexedObject
				)objects.GetFirst();
			AssertEquals("olivier", io2.GetName());
			AssertEquals(15, io2.GetDuration());
			AssertFalse(q.GetExecutionPlan().GetDetails().IndexOf("index1") != -1);
		}
        /// <summary>Test the creation of an index after having created objects.</summary>
        /// <remarks>
        /// Test the creation of an index after having created objects. In this case
        /// ODB should creates the index and update it with already existing objects
        /// </remarks>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test100000Objects()
        {
            string OdbFileName = "index2";

            NeoDatis.Odb.ODB odb = null;
            int  size            = isLocal ? 100000 : 10001;
            long start           = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            NeoDatis.Odb.OdbConfiguration.MonitorMemory(true);
            NeoDatis.Odb.OdbConfiguration.SetReconnectObjectsToSession(false);
            try
            {
                Println("MaxNbObjects/cache = " + NeoDatis.Odb.OdbConfiguration.GetMaxNumberOfObjectInCache
                            ());
                DeleteBase(OdbFileName);
                odb = Open(OdbFileName);
                for (int i = 0; i < size; i++)
                {
                    NeoDatis.Odb.Test.Index.IndexedObject io = new NeoDatis.Odb.Test.Index.IndexedObject
                                                                   ("name" + i, i, new System.DateTime());
                    odb.Store(io);
                    if (i % 10000 == 0)
                    {
                        NeoDatis.Odb.Impl.Tool.MemoryMonitor.DisplayCurrentMemory(i + " objects created",
                                                                                  true);
                    }
                }
                odb.Close();
                Println("\n\n END OF INSERT \n\n");
                odb = Open(OdbFileName);
                string[] names = new string[] { "name" };
                odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject)).AddUniqueIndexOn
                    ("index1", names, true);
                Println("\n\n after create index\n\n");
                NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                                  (typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
                                                                  .Equal("name", "name0")), true);
                Println("\n\nafter get Objects\n\n");
                AssertEquals(1, objects.Count);
                objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(
                                             typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
                                             .Equal("duration", 9)), true);
                AssertEquals(1, objects.Count);
                objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(
                                             typeof(NeoDatis.Odb.Test.Index.IndexedObject)), true);
                AssertEquals(size, objects.Count);
            }
            catch (System.Exception e)
            {
                throw;
            }
            finally
            {
                long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
                Println((end - start) + "ms");
                NeoDatis.Odb.OdbConfiguration.MonitorMemory(false);
                odb.Close();
            }
        }
Esempio n. 6
0
 public virtual int CompareTo(object @object)
 {
     if (@object == null || !(@object is NeoDatis.Odb.Test.Index.IndexedObject))
     {
         return(-1000);
     }
     NeoDatis.Odb.Test.Index.IndexedObject io = (NeoDatis.Odb.Test.Index.IndexedObject
                                                 )@object;
     return(name.CompareTo(io.name));
 }
Esempio n. 7
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test4()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb    = Open(baseName);
            string[]         fields = new string[] { "object" };
            odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject2)).AddUniqueIndexOn
                ("index1", fields, true);
            string[] fields2 = new string[] { "name" };
            odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject)).AddUniqueIndexOn
                ("index2", fields2, true);
            int size = isLocal ? 5000 : 500;

            for (int i = 0; i < size; i++)
            {
                odb.Store(new NeoDatis.Odb.Test.Index.IndexedObject2("Object " + i, new NeoDatis.Odb.Test.Index.IndexedObject
                                                                         ("Inner Object " + i, i, new System.DateTime())));
            }
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                   (typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
                                                   .Equal("name", "Inner Object " + (size - 1)));
            // First get the object used to index, the last one. There is no index
            // on the class and field
            long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            NeoDatis.Odb.Objects objects = odb.GetObjects(q);
            long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            // check if index has been used
            AssertTrue(q.GetExecutionPlan().UseIndex());
            NeoDatis.Odb.Test.Index.IndexedObject io = (NeoDatis.Odb.Test.Index.IndexedObject
                                                        )objects.GetFirst();
            Println("d0=" + (end0 - start0));
            Println(q.GetExecutionPlan().GetDetails());
            q = odb.CriteriaQuery(typeof(NeoDatis.Odb.Test.Index.IndexedObject2), NeoDatis.Odb.Core.Query.Criteria.Where
                                  .Equal("object", io));
            long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            objects = odb.GetObjects(q);
            long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            Println("d=" + (end - start));
            NeoDatis.Odb.Test.Index.IndexedObject2 o2 = (NeoDatis.Odb.Test.Index.IndexedObject2
                                                         )objects.GetFirst();
            odb.Close();
            AssertEquals("Object " + (size - 1), o2.GetName());
            Println(q.GetExecutionPlan().GetDetails());
            AssertTrue(q.GetExecutionPlan().UseIndex());
            DeleteBase(baseName);
        }
        /// <summary>Test the creation of an index after having created objects.</summary>
        /// <remarks>
        /// Test the creation of an index after having created objects. In this case
        /// ODB should creates the index and update it with already existing objects
        /// </remarks>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test20000Objects()
        {
            string OdbFileName = "index2";
            long   start       = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            NeoDatis.Odb.ODB odb = null;
            int size             = isLocal ? 20000 : 2000;

            try
            {
                DeleteBase(OdbFileName);
                odb = Open(OdbFileName);
                for (int i = 0; i < size; i++)
                {
                    NeoDatis.Odb.Test.Index.IndexedObject io = new NeoDatis.Odb.Test.Index.IndexedObject
                                                                   ("name" + i, i, new System.DateTime());
                    odb.Store(io);
                }
                odb.Close();
                odb = Open(OdbFileName);
                string[] names = new string[] { "name" };
                odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject)).AddUniqueIndexOn
                    ("index1", names, true);
                NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                                  (typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
                                                                  .Equal("name", "name0")), true);
                AssertEquals(1, objects.Count);
                objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(
                                             typeof(NeoDatis.Odb.Test.Index.IndexedObject)), true);
                NeoDatis.Odb.Impl.Tool.MemoryMonitor.DisplayCurrentMemory("BTREE", true);
                AssertEquals(size, objects.Count);
            }
            finally
            {
                if (odb != null)
                {
                    odb.Close();
                }
                long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
                Println((end - start) + "ms");
            }
        }
		/// <summary>Test the creation of an index after having created objects.</summary>
		/// <remarks>
		/// Test the creation of an index after having created objects. In this case
		/// ODB should creates the index and update it with already existing objects
		/// </remarks>
		/// <exception cref="System.Exception">System.Exception</exception>
		public virtual void Test20000Objects()
		{
			string OdbFileName = "index2";
			long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			NeoDatis.Odb.ODB odb = null;
			int size = isLocal ? 20000 : 2000;
			try
			{
				DeleteBase(OdbFileName);
				odb = Open(OdbFileName);
				for (int i = 0; i < size; i++)
				{
					NeoDatis.Odb.Test.Index.IndexedObject io = new NeoDatis.Odb.Test.Index.IndexedObject
						("name" + i, i, new System.DateTime());
					odb.Store(io);
				}
				odb.Close();
				odb = Open(OdbFileName);
				string[] names = new string[] { "name" };
				odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject)).AddUniqueIndexOn
					("index1", names, true);
				NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
					(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
					.Equal("name", "name0")), true);
				AssertEquals(1, objects.Count);
				objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(
					typeof(NeoDatis.Odb.Test.Index.IndexedObject)), true);
				NeoDatis.Odb.Impl.Tool.MemoryMonitor.DisplayCurrentMemory("BTREE", true);
				AssertEquals(size, objects.Count);
			}
			finally
			{
				if (odb != null)
				{
					odb.Close();
				}
				long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				Println((end - start) + "ms");
			}
		}
Esempio n. 10
0
		public virtual void SetObject(NeoDatis.Odb.Test.Index.IndexedObject @object)
		{
			this.@object = @object;
		}
Esempio n. 11
0
		public IndexedObject2(string name, NeoDatis.Odb.Test.Index.IndexedObject @object)
			 : base()
		{
			this.name = name;
			this.@object = @object;
		}
Esempio n. 12
0
        public virtual void TestInsertAndDeleteWithIndexWith10000()
		{
			string baseName = GetBaseName();
			if (!runAll)
			{
				return;
			}
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			// base.store(new IndexedObject());
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields = new string[] { "name" };
			clazz.AddUniqueIndexOn("index1", indexFields, true);
			@base.Close();
			@base = Open(baseName);
			int size = 10000;
			long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), 15 + i, new System.DateTime());
				@base.Store(io1);
				if (i % 1000 == 0)
				{
					Println(i);
				}
			}
			long tt0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			@base.Close();
			long tt1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			Println("IPU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbInPlaceUpdates() + " - NU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbNormalUpdates());
			Println("inserting time with index=" + (end0 - start0));
			Println("commit time=" + (tt1 - tt0));
			Println(NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister.Counters());
			@base = Open(baseName);
			long totalSelectTime = 0;
			long maxTime = 0;
			long minTime = 100000;
			long t0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			long t1 = 0;
			long ta1 = 0;
			long ta2 = 0;
			long totalTimeDelete = 0;
			long totalTimeSelect = 0;
			for (int j = 0; j < size; j++)
			{
				NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
					(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
					.Equal("name", "olivier" + (j + 1)));
				long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				NeoDatis.Odb.Objects objects = @base.GetObjects(q, true);
				long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				AssertEquals(1, objects.Count);
				NeoDatis.Odb.Test.Index.IndexedObject io2 = (NeoDatis.Odb.Test.Index.IndexedObject
					)objects.GetFirst();
				AssertEquals("olivier" + (j + 1), io2.GetName());
				AssertEquals(15 + j, io2.GetDuration());
				long d = end - start;
				totalSelectTime += d;
				if (d > maxTime)
				{
					maxTime = d;
				}
				if (d < minTime)
				{
					minTime = d;
				}
				ta1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				@base.Delete(io2);
				ta2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				totalTimeDelete += (ta2 - ta1);
				totalTimeSelect += (end - start);
				if (j % 100 == 0 && j > 0)
				{
					t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
					Println(j + " - t= " + (t1 - t0) + " - delete=" + (totalTimeDelete / j) + " / select="
						 + (totalTimeSelect / j));
					Println(NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister.Counters());
					NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister.ResetCounters();
					t0 = t1;
				}
			}
			@base.Close();
			Println("total select=" + totalSelectTime + " / " + (double)totalSelectTime / size
				);
			Println("total delete=" + totalTimeDelete + " / " + (double)totalTimeDelete / size
				);
			Println("duration max=" + maxTime + " / min=" + minTime);
			@base = Open(baseName);
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
					(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
					.Equal("name", "olivier" + (i + 1)));
				long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				NeoDatis.Odb.Objects objects = @base.GetObjects(q, true);
				long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				AssertEquals(0, objects.Count);
				if (i % 100 == 0)
				{
					Println(i);
				}
			}
			@base.Close();
			DeleteBase(baseName);
			float timePerObject = (float)totalSelectTime / (float)size;
			Println("Time per object = " + timePerObject);
			if (timePerObject > 1)
			{
				Println("Time per object = " + timePerObject);
			}
			AssertTrue(timePerObject < 0.16);
			// TODO Try to get maxTime < 10!
			AssertTrue(maxTime < 250);
			AssertTrue(minTime < 1);
		}
Esempio n. 13
0
        public virtual void TestInsertWithIndex3Part1()
		{
			string baseName = "index.neodatis";
			// LogUtil.logOn(LazyODBBTreePersister.LOG_ID, true);
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			NeoDatis.Odb.OdbConfiguration.SetUseLazyCache(false);
			// base.store(new IndexedObject());
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields = new string[] { "name" };
			clazz.AddUniqueIndexOn("index1", indexFields, true);
			@base.Close();
			@base = Open(baseName);
			int size = 1300;
			int commitInterval = 10;
			long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
				.GetEngine(@base);
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), 15 + size, new System.DateTime());
				@base.Store(io1);
				if (i % commitInterval == 0)
				{
					@base.Commit();
					@base.Close();
					@base = Open(baseName);
					engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine(@base);
				}
				if (io1.GetName().Equals("olivier" + size))
				{
					Println("Ola chico");
				}
			}
			engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine(@base);
			// println(new
			// BTreeDisplay().build(engine.getSession(true).getMetaModel().getClassInfo(IndexedObject.class.getName(),
			// true).getIndex(0).getBTree(), true));
			@base.Close();
			long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
		}
Esempio n. 14
0
        public virtual void TestInsertWith3Keys()
		{
			string baseName = GetBaseName();
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			// base.store(new IndexedObject());
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields = new string[] { "name", "duration", "creation" };
			clazz.AddUniqueIndexOn("index", indexFields, true);
			@base.Close();
			@base = Open(baseName);
			int size = isLocal ? 50000 : 500;
			int commitInterval = isLocal ? 10000 : 100;
			long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Test.Index.IndexedObject io2 = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), i + 15 + size, new System.DateTime());
				@base.Store(io2);
				if (i % commitInterval == 0)
				{
					long t0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
					@base.Commit();
					long t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
					Println(i + " : commit - ctime " + (t1 - t0) + " -ttime=");
					// println(LazyODBBTreePersister.counters());
					NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister.ResetCounters();
				}
			}
			System.DateTime theDate = new System.DateTime();
			string theName = "name indexed";
			int theDuration = 45;
			NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
				(theName, theDuration, theDate);
			@base.Store(io1);
			@base.Close();
			@base = Open(baseName);
			// first search without index
			NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
				.Equal("name", theName));
			NeoDatis.Odb.Objects objects = @base.GetObjects(q, true);
			AssertFalse(q.GetExecutionPlan().UseIndex());
			Println(q.GetExecutionPlan().GetDetails());
			AssertEquals(1, objects.Count);
			NeoDatis.Odb.Test.Index.IndexedObject io3 = (NeoDatis.Odb.Test.Index.IndexedObject
				)objects.GetFirst();
			AssertEquals(theName, io3.GetName());
			AssertEquals(theDuration, io3.GetDuration());
			AssertEquals(theDate, io3.GetCreation());
			@base.Close();
			@base = Open(baseName);
			// Then search usin index
			q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				), NeoDatis.Odb.Core.Query.Criteria.Where.And().Add(NeoDatis.Odb.Core.Query.Criteria.Where
				.Equal("name", theName)).Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("creation"
				, theDate)).Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("duration", theDuration
				)));
			objects = @base.GetObjects(q, true);
			AssertTrue(q.GetExecutionPlan().UseIndex());
			if (isLocal)
			{
				AssertEquals("index", q.GetExecutionPlan().GetIndex().GetName());
			}
			Println(q.GetExecutionPlan().GetDetails());
			AssertEquals(1, objects.Count);
			io3 = (NeoDatis.Odb.Test.Index.IndexedObject)objects.GetFirst();
			AssertEquals(theName, io3.GetName());
			AssertEquals(theDuration, io3.GetDuration());
			AssertEquals(theDate, io3.GetCreation());
			@base.Close();
		}
Esempio n. 15
0
		/// <summary>Test the creation of an index after having created objects.</summary>
		/// <remarks>
		/// Test the creation of an index after having created objects. In this case
		/// ODB should creates the index and update it with already existing objects
		/// </remarks>
		/// <exception cref="System.Exception">System.Exception</exception>
		public virtual void Test100000ObjectsIntiNdex()
		{
			string OdbFileName = "index2";
			NeoDatis.Odb.ODB odb = null;
			int size = isLocal ? 90000 : 10100;
			long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			NeoDatis.Odb.OdbConfiguration.MonitorMemory(true);
			try
			{
				DeleteBase(OdbFileName);
				odb = Open(OdbFileName);
				for (int i = 0; i < size; i++)
				{
					NeoDatis.Odb.Test.Index.IndexedObject io = new NeoDatis.Odb.Test.Index.IndexedObject
						("name" + i, i, new System.DateTime());
					odb.Store(io);
					if (i % 10000 == 0)
					{
						NeoDatis.Odb.Impl.Tool.MemoryMonitor.DisplayCurrentMemory(i + " objects created", 
							true);
					}
				}
				odb.Close();
				Println("\n\n END OF INSERT \n\n");
				odb = Open(OdbFileName);
				string[] names = new string[] { "duration" };
				odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject)).AddUniqueIndexOn
					("index1", names, true);
				Println("\n\n after create index\n\n");
				NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
					(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
					.Equal("name", "name0")), true);
				Println("\n\nafter get Objects\n\n");
				AssertEquals(1, objects.Count);
				objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(
					typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
					.Equal("duration", 10000)), true);
				AssertEquals(1, objects.Count);
				objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(
					typeof(NeoDatis.Odb.Test.Index.IndexedObject)), true);
				AssertEquals(size, objects.Count);
			}
			catch (System.Exception e)
			{
				throw;
			}
			finally
			{
				long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				Println((end - start) + "ms");
				NeoDatis.Odb.OdbConfiguration.MonitorMemory(false);
			}
		}
Esempio n. 16
0
        public virtual void TestInsertWith3Indexes()
		{
			string baseName = GetBaseName();
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			// Configuration.setUseLazyCache(true);
			// base.store(new IndexedObject());
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields3 = new string[] { "name" };
			clazz.AddUniqueIndexOn("index3", indexFields3, true);
			string[] indexFields2 = new string[] { "name", "creation" };
			clazz.AddUniqueIndexOn("index2", indexFields2, true);
			string[] indexField4 = new string[] { "duration", "creation" };
			clazz.AddUniqueIndexOn("inde3", indexField4, true);
			@base.Close();
			@base = Open(baseName);
			int size = isLocal ? 10000 : 1000;
			long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			System.DateTime[] dates = new System.DateTime[size];
			for (int i = 0; i < size; i++)
			{
				// println(i);
				dates[i] = new System.DateTime();
				NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), i, dates[i]);
				@base.Store(io1);
				if (i % 100 == 0)
				{
					Println(i);
				}
			}
			@base.Close();
			long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			Println("IPU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbInPlaceUpdates() + " - NU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbNormalUpdates());
			Println("inserting time with index=" + (end0 - start0));
			@base = Open(baseName);
			long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
					(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
					.And().Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("duration", i)).Add(NeoDatis.Odb.Core.Query.Criteria.Where
					.Equal("creation", dates[i])));
				NeoDatis.Odb.Objects objects = @base.GetObjects(q, true);
				AssertEquals(1, objects.Count);
				AssertTrue(q.GetExecutionPlan().UseIndex());
			}
			long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			double duration = (end - start);
			duration = duration / size;
			Println("duration=" + duration);
			@base.Close();
			DeleteBase(baseName);
			NeoDatis.Odb.OdbConfiguration.SetUseLazyCache(false);
			Println(duration);
			double d = 0.11;
			if (!isLocal)
			{
				d = 10;
			}
			if (duration > d)
			{
				Fail("Time of search in index is greater than " + d + " ms : " + duration);
			}
		}
Esempio n. 17
0
        public virtual void TestIndexWithOneFieldAndQueryWithTwoFields()
		{
			string baseName = GetBaseName();
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields = new string[] { "name" };
			clazz.AddUniqueIndexOn("index1", indexFields, true);
			@base.Close();
			@base = Open(baseName);
			NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
				("olivier", 15, new System.DateTime());
			@base.Store(io1);
			@base.Close();
			@base = Open(baseName);
			NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
				.And().Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("name", "olivier")).Add(
				NeoDatis.Odb.Core.Query.Criteria.Where.Equal("duration", 15)));
			NeoDatis.Odb.Objects objects = @base.GetObjects(q, true);
			@base.Close();
			Println(q.GetExecutionPlan().ToString());
			AssertEquals(false, q.GetExecutionPlan().UseIndex());
			AssertEquals(1, objects.Count);
			DeleteBase(baseName);
		}
Esempio n. 18
0
        public virtual void TestInsertWithoutIndex3()
		{
			string baseName = GetBaseName();
			if (!runAll)
			{
				return;
			}
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			int size = 30000;
			int commitInterval = 1000;
			long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), 15 + size, new System.DateTime());
				@base.Store(io1);
				if (i % commitInterval == 0)
				{
					@base.Commit();
				}
			}
			// println(i+" : commit");
			@base.Close();
			long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			Println("IPU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbInPlaceUpdates() + " - NU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbNormalUpdates());
			Println("inserting time with index=" + (end0 - start0));
			@base = Open(baseName);
			NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
				.Equal("name", "olivier" + size));
			long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			NeoDatis.Odb.Objects objects = @base.GetObjects(q, false);
			long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			AssertEquals(1, objects.Count);
			NeoDatis.Odb.Test.Index.IndexedObject io2 = (NeoDatis.Odb.Test.Index.IndexedObject
				)objects.GetFirst();
			AssertEquals("olivier" + size, io2.GetName());
			AssertEquals(15 + size, io2.GetDuration());
			long duration = end - start;
			Println("duration=" + duration);
			@base.Close();
			DeleteBase(baseName);
			NeoDatis.Odb.OdbConfiguration.SetUseLazyCache(false);
			Println(duration);
			double d = 408;
			if (!isLocal)
			{
				d = 3500;
			}
			if (duration > d)
			{
				Fail("Time of search in index is greater than " + d + " ms : " + duration);
			}
		}
Esempio n. 19
0
        public virtual void TestInsertWith3IndexesCheckAll()
		{
			string baseName = GetBaseName();
			// LogUtil.logOn(LazyODBBTreePersister.LOG_ID, true);
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			NeoDatis.Odb.OdbConfiguration.SetUseLazyCache(false);
			// base.store(new IndexedObject());
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields = new string[] { "duration" };
			clazz.AddIndexOn("index1", indexFields, true);
			string[] indexFields2 = new string[] { "creation" };
			clazz.AddIndexOn("index2", indexFields2, true);
			string[] indexFields3 = new string[] { "name" };
			clazz.AddIndexOn("index3", indexFields3, true);
			@base.Close();
			@base = Open(baseName);
			int size = 1300;
			int commitInterval = 10;
			long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), i, new System.DateTime());
				@base.Store(io1);
				if (i % commitInterval == 0)
				{
					@base.Commit();
					Println(i + " : commit / " + size);
				}
			}
			@base.Close();
			long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			// println("IPU=" + ObjectWriter.getNbInPlaceUpdates() + " - NU=" +
			// ObjectWriter.getNbNormalUpdates());
			// println("inserting time with index=" + (end0 - start0));
			@base = Open(baseName);
			long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
					(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
					.Equal("duration", i));
				NeoDatis.Odb.Objects objects = @base.GetObjects(q, false);
				// println("olivier" + (i+1));
				AssertEquals(1, objects.Count);
			}
			long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			try
			{
				float duration = (float)(end - start) / (float)size;
				Println(duration);
				double d = 0.144;
				if (!isLocal)
				{
					d = 1.16;
				}
				if (testPerformance && duration > d)
				{
					Fail("Time of search in index is greater than " + d + " ms : " + duration);
				}
			}
			finally
			{
				@base.Close();
				DeleteBase(baseName);
			}
		}
Esempio n. 20
0
        public virtual void TestXUpdatesWithIndex()
		{
			string baseName = GetBaseName();
			try
			{
				DeleteBase(baseName);
				NeoDatis.Odb.ODB @base = Open(baseName);
				// base.store(new IndexedObject());
				NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
					));
				string[] indexFields = new string[] { "name" };
				clazz.AddUniqueIndexOn("index", indexFields, true);
				@base.Close();
				@base = Open(baseName);
				long start = Sharpen.Runtime.CurrentTimeMillis();
				int size = 1000;
				int nbObjects = 10;
				int nbUpdates = isLocal ? 100 : 50;
				for (int i = 0; i < size; i++)
				{
					NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
						("IO-" + i + "-0", i + 15 + size, new System.DateTime());
					@base.Store(io1);
				}
				@base.Close();
				Println("Time of insert " + size + " objects = " + size);
				string[] indexes = new string[] { "IO-0-0", "IO-100-0", "IO-200-0", "IO-300-0", "IO-400-0"
					, "IO-500-0", "IO-600-0", "IO-700-0", "IO-800-0", "IO-900-0" };
				long t1 = 0;
				long t2 = 0;
				long t3 = 0;
				long t4 = 0;
				long t5 = 0;
				long t6 = 0;
				for (int i = 0; i < nbUpdates; i++)
				{
					start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
					for (int j = 0; j < nbObjects; j++)
					{
						t1 = Sharpen.Runtime.CurrentTimeMillis();
						@base = Open(baseName);
						t2 = Sharpen.Runtime.CurrentTimeMillis();
						NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
							(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
							.Equal("name", indexes[j]));
						NeoDatis.Odb.Objects os = @base.GetObjects(q);
						t3 = Sharpen.Runtime.CurrentTimeMillis();
						AssertTrue(q.GetExecutionPlan().UseIndex());
						AssertEquals(1, os.Count);
						// check if index has been used
						AssertTrue(q.GetExecutionPlan().UseIndex());
						NeoDatis.Odb.Test.Index.IndexedObject io = (NeoDatis.Odb.Test.Index.IndexedObject
							)os.GetFirst();
						if (i > 0)
						{
							AssertTrue(io.GetName().EndsWith(("-" + (i - 1))));
						}
						io.SetName(io.GetName() + "-updated-" + i);
						@base.Store(io);
						t4 = Sharpen.Runtime.CurrentTimeMillis();
						if (isLocal && j == 0)
						{
							NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
								.GetEngine(@base);
							NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = engine.GetSession(true).GetMetaModel
								().GetClassInfo(typeof(NeoDatis.Odb.Test.Index.IndexedObject).FullName, true);
							NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex cii = ci.GetIndex(0);
							AssertEquals(size, cii.GetBTree().GetSize());
						}
						indexes[j] = io.GetName();
						AssertEquals(new System.Decimal(string.Empty + size), @base.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
							(typeof(NeoDatis.Odb.Test.Index.IndexedObject))));
						t5 = Sharpen.Runtime.CurrentTimeMillis();
						@base.Commit();
						@base.Close();
						t6 = Sharpen.Runtime.CurrentTimeMillis();
					}
					long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
					System.Console.Out.WriteLine("Nb Updates of " + nbObjects + " =" + i + " - " + (end
						 - start) + "ms  -- open=" + (t2 - t1) + " - getObjects=" + (t3 - t2) + " - update="
						 + (t4 - t3) + " - count=" + (t5 - t4) + " - close=" + (t6 - t5));
				}
			}
			finally
			{
			}
		}
Esempio n. 21
0
 public IndexedObject2(string name, NeoDatis.Odb.Test.Index.IndexedObject @object)
     : base()
 {
     this.name    = name;
     this.@object = @object;
 }
Esempio n. 22
0
        public virtual void TestInsertWithIndex4()
		{
			string baseName = GetBaseName();
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			// base.store(new IndexedObject());
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields3 = new string[] { "name" };
			clazz.AddUniqueIndexOn("index3", indexFields3, true);
			string[] indexFields2 = new string[] { "name", "creation" };
			clazz.AddUniqueIndexOn("index2", indexFields2, true);
			string[] indexField4 = new string[] { "duration", "creation" };
			clazz.AddUniqueIndexOn("inde3", indexField4, true);
			@base.Close();
			@base = Open(baseName);
			int size = isLocal ? 50000 : 1000;
			int commitInterval = 1000;
			long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			for (int i = 0; i < size; i++)
			{
				// println(i);
				NeoDatis.Odb.Test.Index.IndexedObject ioio = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), i + 15 + size, new System.DateTime());
				@base.Store(ioio);
				if (i % commitInterval == 0)
				{
					long t0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
					@base.Commit();
					long t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
					Println(i + " : commit - ctime " + (t1 - t0) + " -ttime=");
					// println(LazyODBBTreePersister.counters());
					NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister.ResetCounters();
				}
			}
			System.DateTime theDate = new System.DateTime();
			string theName = "name indexed";
			NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
				(theName, 45, theDate);
			@base.Store(io1);
			@base.Close();
			long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			Println("IPU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbInPlaceUpdates() + " - NU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbNormalUpdates());
			Println("inserting time with index=" + (end0 - start0));
			@base = Open(baseName);
			// IQuery q = new
			// CriteriaQuery(IndexedObject.class,Restrictions.and().add(Restrictions.equal("name",theName)).add(Restrictions.equal("creation",
			// theDate)));
			NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
				.Equal("name", theName));
			long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			NeoDatis.Odb.Objects objects = @base.GetObjects(q, true);
			long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			if (isLocal)
			{
				AssertEquals("index3", q.GetExecutionPlan().GetIndex().GetName());
			}
			AssertEquals(1, objects.Count);
			NeoDatis.Odb.Test.Index.IndexedObject io2 = (NeoDatis.Odb.Test.Index.IndexedObject
				)objects.GetFirst();
			AssertEquals(theName, io2.GetName());
			AssertEquals(45, io2.GetDuration());
			AssertEquals(theDate, io2.GetCreation());
			long duration = end - start;
			Println("duration=" + duration);
			@base.Close();
			DeleteBase(baseName);
			NeoDatis.Odb.OdbConfiguration.SetUseLazyCache(false);
			if (testPerformance && duration > 1)
			{
				Fail("Time of search in index > 1 : " + duration);
			}
		}
Esempio n. 23
0
 public virtual void SetObject(NeoDatis.Odb.Test.Index.IndexedObject @object)
 {
     this.@object = @object;
 }
Esempio n. 24
0
        public virtual void TestInsertAndDeleteWithIndex()
		{
			string baseName = GetBaseName();
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			// base.store(new IndexedObject());
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields = new string[] { "name" };
			clazz.AddUniqueIndexOn("index1", indexFields, true);
			@base.Close();
			@base = Open(baseName);
			int size = 1000;
			long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), 15 + i, new System.DateTime());
				@base.Store(io1);
				if (i % 1000 == 0)
				{
					Println(i);
				}
			}
			long tt0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			@base.Close();
			long tt1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			Println("IPU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbInPlaceUpdates() + " - NU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbNormalUpdates());
			Println("inserting time with index=" + (end0 - start0));
			Println("commit time=" + (tt1 - tt0));
			Println(NeoDatis.Odb.Impl.Core.Btree.LazyODBBTreePersister.Counters());
			@base = Open(baseName);
			long totalTime = 0;
			long maxTime = 0;
			long minTime = 100000;
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
					(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
					.Equal("name", "olivier" + (i + 1)));
				long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				NeoDatis.Odb.Objects objects = @base.GetObjects(query, true);
				long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
				AssertEquals(1, objects.Count);
				NeoDatis.Odb.Test.Index.IndexedObject io2 = (NeoDatis.Odb.Test.Index.IndexedObject
					)objects.GetFirst();
				AssertEquals("olivier" + (i + 1), io2.GetName());
				AssertEquals(15 + i, io2.GetDuration());
				long d = end - start;
				totalTime += d;
				if (d > maxTime)
				{
					maxTime = d;
				}
				if (d < minTime)
				{
					minTime = d;
				}
				@base.Delete(io2);
			}
			@base.Close();
			@base = Open(baseName);
			NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.Index.IndexedObject));
			NeoDatis.Odb.Objects oos = @base.GetObjects(q, true);
			for (int i = 0; i < size; i++)
			{
				q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof(NeoDatis.Odb.Test.Index.IndexedObject
					), NeoDatis.Odb.Core.Query.Criteria.Where.Equal("name", "olivier" + (i + 1)));
				oos = @base.GetObjects(q, true);
				AssertEquals(0, oos.Count);
			}
			@base.Close();
			DeleteBase(baseName);
			Println("total duration=" + totalTime + " / " + (double)totalTime / size);
			Println("duration max=" + maxTime + " / min=" + minTime);
			if (testPerformance)
			{
				AssertTrue(totalTime / size < 0.9);
				// TODO Try to get maxTime < 10!
				AssertTrue(maxTime < 20);
				AssertTrue(minTime == 0);
			}
		}
Esempio n. 25
0
        public virtual void TestInsertAndDeleteWithIndex1()
		{
			string baseName = GetBaseName();
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			// base.store(new IndexedObject());
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields = new string[] { "name" };
			clazz.AddUniqueIndexOn("index1", indexFields, true);
			@base.Close();
			@base = Open(baseName);
			int size = 1400;
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), 15 + i, new System.DateTime());
				@base.Store(io1);
			}
			@base.Close();
			System.Console.Out.WriteLine("----ola");
			@base = Open(baseName);
			NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.Index.IndexedObject));
			NeoDatis.Odb.Objects<NeoDatis.Odb.Test.Index.IndexedObject> objects = @base.GetObjects
				(q);
			while (objects.HasNext())
			{
				NeoDatis.Odb.Test.Index.IndexedObject io = objects.Next();
				Println(io);
				@base.Delete(io);
			}
			@base.Close();
		}
Esempio n. 26
0
        public virtual void TestSizeBTree()
		{
			if (!isLocal)
			{
				return;
			}
			string baseName = GetBaseName();
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			// base.store(new IndexedObject());
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields = new string[] { "name" };
			clazz.AddUniqueIndexOn("index1", indexFields, true);
			@base.Close();
			@base = Open(baseName);
			int size = 4;
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), 15 + i, new System.DateTime());
				@base.Store(io1);
				if (i % 1000 == 0)
				{
					Println(i);
				}
			}
			@base.Close();
			@base = Open(baseName);
			NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine e = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
				.GetEngine(@base);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex cii = e.GetSession(true).GetMetaModel
				().GetClassInfo(typeof(NeoDatis.Odb.Test.Index.IndexedObject).FullName, true).GetIndex
				(0);
			@base.Close();
			DeleteBase(baseName);
			AssertEquals(size, cii.GetBTree().GetSize());
		}
Esempio n. 27
0
        public virtual void TestInsertWith4IndexesAndCommits()
		{
			string baseName = GetBaseName();
			if (!runAll)
			{
				return;
			}
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			// Configuration.setUseLazyCache(true);
			// base.store(new IndexedObject());
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexField1 = new string[] { "duration" };
			clazz.AddUniqueIndexOn("inde1", indexField1, true);
			string[] indexFields3 = new string[] { "name" };
			clazz.AddUniqueIndexOn("index3", indexFields3, true);
			string[] indexFields2 = new string[] { "name", "creation" };
			clazz.AddUniqueIndexOn("index2", indexFields2, true);
			string[] indexField4 = new string[] { "duration", "creation" };
			clazz.AddUniqueIndexOn("inde4", indexField4, true);
			@base.Close();
			@base = Open(baseName);
			int size = 10000;
			int commitInterval = 10;
			long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			for (int i = 0; i < size; i++)
			{
				// println(i);
				NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), i, new System.DateTime());
				@base.Store(io1);
				if (i % 1000 == 0)
				{
					Println(i);
				}
				if (i % commitInterval == 0)
				{
					@base.Commit();
				}
			}
			@base.Close();
			long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			Println("IPU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbInPlaceUpdates() + " - NU=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter
				.GetNbNormalUpdates());
			Println("inserting time with index=" + (end0 - start0));
			@base = Open(baseName);
			long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
					(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
					.Equal("duration", i));
				NeoDatis.Odb.Objects objects = @base.GetObjects(q, false);
				// println("olivier" + (i+1));
				AssertEquals(1, objects.Count);
			}
			long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			long duration = end - start;
			Println("duration=" + duration);
			@base.Close();
			DeleteBase(baseName);
			NeoDatis.Odb.OdbConfiguration.SetUseLazyCache(false);
			if (testPerformance && duration > 111)
			{
				Fail("Time of search in index : " + duration + ", should be less than 111");
			}
		}
Esempio n. 28
0
        public virtual void TestInsertWithIndex3()
		{
			string baseName = GetBaseName();
			// LogUtil.logOn(LazyODBBTreePersister.LOG_ID, true);
			DeleteBase(baseName);
			NeoDatis.Odb.ODB @base = Open(baseName);
			NeoDatis.Odb.OdbConfiguration.SetUseLazyCache(false);
			// base.store(new IndexedObject());
			NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject
				));
			string[] indexFields = new string[] { "name" };
			clazz.AddUniqueIndexOn("index1", indexFields, true);
			@base.Close();
			@base = Open(baseName);
			int size = isLocal ? 1300 : 300;
			int commitInterval = 10;
			long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy
				.GetEngine(@base);
			for (int i = 0; i < size; i++)
			{
				NeoDatis.Odb.Test.Index.IndexedObject io1 = new NeoDatis.Odb.Test.Index.IndexedObject
					("olivier" + (i + 1), 15 + size, new System.DateTime());
				@base.Store(io1);
				if (i % commitInterval == 0)
				{
					@base.Commit();
					@base.Close();
					@base = Open(baseName);
					engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine(@base);
				}
				if (io1.GetName().Equals("olivier" + size))
				{
					Println("Ola chico");
				}
			}
			engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine(@base);
			// println(new
			// BTreeDisplay().build(engine.getSession(true).getMetaModel().getClassInfo(IndexedObject.class.getName(),
			// true).getIndex(0).getBTree(), true));
			@base.Close();
			long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			// println("IPU=" + ObjectWriter.getNbInPlaceUpdates() + " - NU=" +
			// ObjectWriter.getNbNormalUpdates());
			// println("inserting time with index=" + (end0 - start0));
			@base = Open(baseName);
			engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine(@base);
			// println("After load = unconnected : "+
			// engine.getSession(true).getMetaModel().getClassInfo(IndexedObject.class.getName(),
			// true).getUncommittedZoneInfo());
			// println("After Load = connected : "+
			// engine.getSession(true).getMetaModel().getClassInfo(IndexedObject.class.getName(),
			// true).getCommitedZoneInfo());
			// println(new
			// BTreeDisplay().build(engine.getSession(true).getMetaModel().getClassInfo(IndexedObject.class.getName(),
			// true).getIndex(0).getBTree(), true));
			NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
				(typeof(NeoDatis.Odb.Test.Index.IndexedObject), NeoDatis.Odb.Core.Query.Criteria.Where
				.Equal("name", "olivier" + size));
			long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			NeoDatis.Odb.Objects objects = @base.GetObjects(q, false);
			long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();
			try
			{
				AssertEquals(1, objects.Count);
				NeoDatis.Odb.Test.Index.IndexedObject io2 = (NeoDatis.Odb.Test.Index.IndexedObject
					)objects.GetFirst();
				AssertEquals("olivier" + size, io2.GetName());
				AssertEquals(15 + size, io2.GetDuration());
				long duration = end - start;
				Println("duration=" + duration);
				NeoDatis.Odb.OdbConfiguration.SetUseLazyCache(false);
				if (testPerformance)
				{
					if (isLocal)
					{
						if (duration > 2)
						{
							Fail("Time of search in index is greater than 2ms : " + duration);
						}
					}
					else
					{
						if (duration > 32)
						{
							Fail("Time of search in index is greater than 2ms : " + duration);
						}
					}
				}
			}
			finally
			{
				@base.Close();
				DeleteBase(baseName);
			}
		}