Esempio n. 1
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. 2
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);
			}
		}