public virtual void Test8RollbackDeleteAndStore() { DeleteBase("rollback.neodatis"); NeoDatis.Odb.ODB odb = Open("rollback.neodatis", "u1", "p1"); odb.Store(new Function("f1")); odb.Store(new Function("f2")); odb.Store(new Function("f3")); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(); while (objects.HasNext()) { Function f = (Function)objects .Next(); f.SetName(OdbString.Substring(f.GetName(), 1)); odb.Store(f); } objects.Reset(); while (objects.HasNext()) { odb.Delete(objects.Next()); } for (int i = 0; i < 500; i++) { odb.Store(new Function("f3 - " + i)); } odb.Rollback(); odb.Close(); odb = Open("rollback.neodatis", "u1", "p1"); AssertEquals(3, odb.GetObjects <Function>().Count ); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { DeleteBase("sict"); NeoDatis.Odb.ODB odb = Open("sict"); NeoDatis.Odb.Test.Update.Nullobject.User user = Popula(odb); AT at = CreateAT(user); odb.Store(at); odb.Store(CreateSensor(user, at, 1)); odb.Store(CreateSensor(user, at, 2)); odb.Store(CreateSensor(user, at, 3)); odb.Store(CreateSensor(user, at, 4)); odb.Close(); odb = Open("sict"); NeoDatis.Odb.Objects <AT> ats = odb.GetObjects <AT>(); int nbAts = ats.Count; at = (AT)ats.GetFirst(); AT newAT = null; SensorAT newSensor = null; NeoDatis.Odb.Core.Query.IQuery query = new CriteriaQuery(Where.Equal("at.name", at.GetName())); query.OrderByAsc("lane"); NeoDatis.Odb.Objects <SensorAT> sensors = odb.GetObjects <SensorAT>(query); Println("Duplicando AT " + at.GetName()); for (int i = 0; i < 10; i++) { newAT = DuplicateAT(at, nbAts + i + 1); odb.Store(newAT); sensors.Reset(); while (sensors.HasNext()) { newSensor = DuplicateSensor((SensorAT)sensors .Next(), newAT); odb.Store(newSensor); } } // println("AT " + newAT.getName()+" created"); odb.Close(); }
public virtual void Test1WithCommit4() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function1"); odb.Store(f1); Function f2 = new Function( "function2"); odb.Store(f2); odb.Close(); odb = Open(FileName); NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(); Function f = null; Println("got the object " + objects.Count); for (int k = 0; k < 2; k++) { objects.Reset(); while (objects.HasNext()) { f = (Function)objects.Next(); f.SetName(f.GetName() + "updated-"); odb.Store(f); } } odb.Close(); odb = Open(FileName); objects = odb.GetObjects <Function>(); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void TestInsertSimpleObjectODB() { bool inMemory = true; // Deletes the database file NeoDatis.Tool.IOUtil.DeleteFile(OdbFileName); long t1 = 0; long t2 = 0; long t3 = 0; long t4 = 0; long t5 = 0; long t6 = 0; long t7 = 0; long t77 = 0; long t8 = 0; NeoDatis.Odb.ODB odb = null; NeoDatis.Odb.Objects l = null; NeoDatis.Odb.Test.VO.Login.User so = null; // Insert TEST_SIZE objects System.Console.Out.WriteLine("Inserting " + TestSize + " objects"); t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName); odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.VO.Login.User)).AddFullInstantiationHelper (new NeoDatis.Odb.Test.Performance.UserFullInstantiationHelper()); for (int i = 0; i < TestSize; i++) { object o = GetUserInstance(i); odb.Store(o); } t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // Closes the database odb.Close(); t3 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); System.Console.Out.WriteLine("Retrieving " + TestSize + " objects"); // Reopen the database odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName); // Gets retrieve the TEST_SIZE objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User), inMemory); t4 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // Actually get objects while (l.HasNext()) { object o = l.Next(); } t5 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); System.Console.Out.WriteLine("Updating " + TestSize + " objects"); so = null; l.Reset(); // Actually get objects while (l.HasNext()) { so = (NeoDatis.Odb.Test.VO.Login.User)l.Next(); // so.setName(so.getName() + " updated"); // so.setName(so.getName() + " updated-updated-updated-updated"); so.GetProfile().SetName(so.GetName() + " updated-updated-updated"); odb.Store(so); } t6 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb.Close(); t7 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); System.Console.Out.WriteLine("Deleting " + TestSize + " objects"); odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName); l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.User), inMemory); t77 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // Actually get objects while (l.HasNext()) { so = (NeoDatis.Odb.Test.VO.Login.User)l.Next(); odb.Delete(so); } odb.Close(); t8 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb = NeoDatis.Odb.ODBFactory.Open(OdbFileName); odb.Close(); DisplayResult("ODB " + TestSize + " User objects ", t1, t2, t3, t4, t5, t6, t7, t77 , t8); }
public virtual void Test1WithCommit2() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); int size = 2; int size2 = 1; int nbFunctions = 1; DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function 1"); Println(odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( User)))); // Create Objects for (int i = 0; i < size; i++) { NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number " + i, f1); for (int j = 0; j < nbFunctions; j++) { p.AddFunction(new Function(" inner function of profile : number " + i + " - " + j)); } User user = new User("user name " + i, "user email " + i, p); odb.Store(user); if (i % 100 == 0) { Println("insert " + i); } } odb.Close(); Println("created"); // Updates 10 times the objects odb = Open(FileName); NeoDatis.Odb.Objects <User> objects = odb.GetObjects <User>(); Println("got the object " + objects.Count); for (int k = 0; k < 3; k++) { objects.Reset(); long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); for (int i = 0; i < size; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated"); odb.Store(user); if (i % 100 == 0) { Println("update " + i + " - " + k); } } Println("Update " + k + " - " + (NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs () - start) + " ms"); } Println("updated"); Println("deleted"); odb.Close(); // Check object count odb = Open(FileName); objects = odb.GetObjects <User>(); AssertEquals(objects.Count, size); // Check data of the objects int a = 0; while (objects.HasNext()) { User user = (User)objects.Next (); AssertEquals("user name " + a, user.GetName()); AssertEquals("user email " + a, user.GetEmail()); AssertEquals("profile number " + a + "-updated-updated-updated", user.GetProfile( ).GetName()); a++; } Println("checked"); for (int k = 0; k < 10; k++) { objects.Reset(); for (int i = 0; i < size2; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-"); odb.Store(user); } } Println("re-updated"); odb.Close(); // delete objects odb = Open(FileName); objects = odb.GetObjects <User>(); a = 0; while (objects.HasNext()) { odb.Delete(objects.Next()); a++; } AssertEquals(size, a); odb.Close(); odb = Open(FileName); AssertEquals(0, odb.GetObjects <User>().Count); AssertEquals(0, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(User)))); Println("deleted"); odb.Close(); stopWatch.End(); Println("Total time 1 = " + stopWatch.GetDurationInMiliseconds()); if (stopWatch.GetDurationInMiliseconds() > 90700) { Fail("time is > than " + 90700 + " = " + stopWatch.GetDurationInMiliseconds()); } }
public virtual void Test1WithoutCommit() { if (!runAll) { return; } NeoDatis.Tool.StopWatch stopWatch = new NeoDatis.Tool.StopWatch(); stopWatch.Start(); int size = 10000; int size2 = 5000; int nbFunctions = 10; DeleteBase(FileName); NeoDatis.Odb.ODB odb = Open(FileName); Function f1 = new Function( "function 1"); // Create Objects for (int i = 0; i < size; i++) { NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("profile number " + i, f1); for (int j = 0; j < nbFunctions; j++) { p.AddFunction(new Function(" inner function of profile : number " + i + " - " + j)); } User user = new User("user name " + i, "user email " + i, p); odb.Store(user); } Println("created"); // Updates 10 times the objects NeoDatis.Odb.Objects <User> objects = odb.GetObjects <User>(); for (int k = 0; k < 10; k++) { objects.Reset(); for (int i = 0; i < size2; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated"); odb.Store(user); } } Println("updated"); // Delete the rest of the objects for (int i = size2; i < size; i++) { odb.Delete(objects.Next()); } Println("deleted"); // Check object count objects = odb.GetObjects <User>(); AssertEquals(size2, objects.Count); // Check data of the objects int a = 0; while (objects.HasNext()) { User user = (User)objects.Next (); AssertEquals("user name " + a, user.GetName()); AssertEquals("user email " + a, user.GetEmail()); AssertEquals("profile number " + a + "-updated-updated-updated-updated-updated-updated-updated-updated-updated-updated" , user.GetProfile().GetName()); a++; } Println("checked"); for (int k = 0; k < 10; k++) { objects.Reset(); for (int i = 0; i < size2; i++) { User user = (User)objects.Next (); user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-"); odb.Store(user); } } Println("re-updated"); objects = odb.GetObjects <User>(); NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy .GetEngine(odb); NeoDatis.Odb.Core.Layers.Layer2.Meta.CIZoneInfo uncommited = engine.GetSession(true ).GetMetaModel().GetClassInfo(typeof(User).FullName, true).GetUncommittedZoneInfo(); NeoDatis.Odb.Core.Layers.Layer2.Meta.CIZoneInfo commited = engine.GetSession(true ).GetMetaModel().GetClassInfo(typeof(User).FullName, true).GetCommitedZoneInfo(); Println("Before commit : uncommited=" + uncommited); Println("Before commit : commited=" + commited); a = 0; while (objects.HasNext()) { // println("a="+a); odb.Delete(objects.Next()); a++; } AssertEquals(size2, a); AssertEquals(0, odb.GetObjects <User>().Count); AssertEquals(0, odb.Count(new CriteriaQuery(typeof(User)))); Println("deleted"); odb.Close(); stopWatch.End(); Println("Total time 2 = " + stopWatch.GetDurationInMiliseconds()); if (stopWatch.GetDurationInMiliseconds() > 108438) { Fail("time is > than " + 108438 + " = " + stopWatch.GetDurationInMiliseconds()); } }
public virtual void TestInsertSimpleObjectODB(bool force) { if (!force && !runAll) { return; } bool reconnectStatus = NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession(); //OdbConfiguration.setReconnectObjectsToSession(false); // Thread.sleep(20000); bool doUpdate = true; bool doDelete = true; // Configuration.setDatabaseCharacterEncoding(null); // LogUtil.logOn(FileSystemInterface.LOG_ID,true); // LogUtil.logOn(ObjectReader.LOG_ID,true); // Configuration.setUseLazyCache(true); bool inMemory = true; // Configuration.monitorMemory(true); // Configuration.setUseModifiedClass(true); // Deletes the database file DeleteBase(OdbFileName); long t1 = 0; long t2 = 0; long t3 = 0; long t4 = 0; long t5 = 0; long t6 = 0; long t7 = 0; long t77 = 0; long t8 = 0; NeoDatis.Odb.ODB odb = null; NeoDatis.Odb.Objects <SimpleObject> l = null; NeoDatis.Odb.Test.Performance.SimpleObject so = null; // Insert TEST_SIZE objects Println("Inserting " + TestSize + " objects"); t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb = Open(OdbFileName); int i = 0; // odb.getClassRepresentation(SimpleObject.class).addFullInstantiationHelper(new // SimpleObjectFullInstantiationHelper()); for (i = 0; i < TestSize; i++) { object o = GetSimpleObjectInstance(i); odb.Store(o); if (i % 10000 == 0) { } } // println("i="+i); // Monitor.displayCurrentMemory(""+i,true); // println("Cache="+Dummy.getEngine(odb).getSession().getCache().toString()); t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // Closes the database odb.Close(); // if(true)return; t3 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); Println("Retrieving " + TestSize + " objects"); // Reopen the database odb = Open(OdbFileName); // Gets the TEST_SIZE objects l = odb.GetObjects <SimpleObject>(inMemory); t4 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); i = 0; while (l.HasNext()) { object o = l.Next(); if (i % 10000 == 0) { } // Monitor.displayCurrentMemory("select "+i,true); i++; } t5 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); if (doUpdate) { Println("Updating " + TestSize + " objects"); i = 0; so = null; l.Reset(); while (l.HasNext()) { so = (NeoDatis.Odb.Test.Performance.SimpleObject)l.Next(); so.SetName(so.GetName() + " updated"); odb.Store(so); if (i % 10000 == 0) { } // Monitor.displayCurrentMemory(""+i); i++; } } t6 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb.Close(); t7 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); if (doDelete) { Println("Deleting " + TestSize + " objects"); odb = Open(OdbFileName); l = odb.GetObjects <SimpleObject>(inMemory); t77 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // println("After getting objects - before delete"); i = 0; while (l.HasNext()) { so = (NeoDatis.Odb.Test.Performance.SimpleObject)l.Next(); if (!so.GetName().EndsWith("updated")) { throw new System.Exception("Update not ok for " + so.GetName()); } odb.Delete(so); if (i % 10000 == 0) { } // println("s="+i); i++; } odb.Close(); } Thread.Sleep(500); t8 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.OdbConfiguration.SetReconnectObjectsToSession(reconnectStatus); DisplayResult("ODB " + TestSize + " SimpleObject objects ", t1, t2, t3, t4, t5, t6 , t7, t77, t8); }
public virtual void TestInsertUserODB() { DeleteBase(OdbFileName); long t1; long t2; long t3; long t4; long t5; long t6; long t7; long t77; long t8; t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.ODB odb = Open(OdbFileName); for (int i = 0; i < TestSize; i++) { object o = GetUserInstance(); odb.Store(o); if (i % 1000 == 0) { System.Console.Out.Write("."); } } t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // assertEquals(TEST_SIZE, // odb.getSession().getCache().getNumberOfObjects ()); NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy .GetEngine(odb); if (isLocal) { Println("NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions ()); } odb.Commit(); t3 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); Println("end of insert"); NeoDatis.Odb.Objects <User> l = odb.GetObjects <User>(false); t4 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); int nbObjects = l.Count; Println(nbObjects + " objects "); User user = null; while (l.HasNext()) { // println(i); user = (User)l.Next(); } // assertEquals(TEST_SIZE, // odb.getSession().getCache().getNumberOfObjects ()); Println("end of real get objects"); t5 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); user = null; int j = 0; l.Reset(); while (l.HasNext()) { // println(i); user = (User)l.Next(); user.SetName(user.GetName() + " updated" + j); odb.Store(user); j++; } t6 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); Println("end of update"); odb.Close(); t7 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb = Open(OdbFileName); l = odb.GetObjects <User>(); t77 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); j = 0; while (l.HasNext()) { user = (User)l.Next(); Println(j + " " + user.GetName()); AssertTrue(user.GetName().EndsWith("updated" + j)); odb.Delete(user); j++; } odb.Close(); t8 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb = Open(OdbFileName); AssertEquals(0, odb.GetObjects <User>().Count); odb.Close(); DisplayResult("ODB " + TestSize + " User objects ", t1, t2, t3, t4, t5, t6, t7, t77 , t8); DeleteBase(OdbFileName); }
public virtual void TestInsertSimpleObjectODB() { DeleteBase(OdbFileName); long t1 = 0; long t2 = 0; long t3 = 0; long t4 = 0; long t5 = 0; long t6 = 0; long t7 = 0; long t77 = 0; long t8 = 0; NeoDatis.Odb.ODB odb = null; NeoDatis.Odb.Objects <SimpleObject> l = null; SimpleObject so = null; t1 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb = Open(OdbFileName); for (int i = 0; i < TestSize; i++) { object o = GetSimpleObjectInstance(i); odb.Store(o); if (i % 20000 == 0) { System.Console.Out.Write("."); Println("After insert=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine (odb).GetSession(true).GetCache().ToString()); } } // NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy .GetEngine(odb); if (isLocal) { // println("NB WA="+WriteAction.count); Println("NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions ()); } t2 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb.Commit(); if (isLocal) { Println("after commit : NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions ()); } // if(true)return; // println("After commit="+Dummy.getEngine(odb).getSession().getCache().toString()); // println("NB WA="+WriteAction.count); t3 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // println("end of insert"); l = odb.GetObjects <SimpleObject>(false); // println("end of getObjects "); t4 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); // println("After getObjects ="+Dummy.getEngine(odb).getSession().getCache().toString()); // println("NB WA="+WriteAction.count); if (isLocal) { Println("after select : NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions ()); } int nbObjects = l.Count; Println(nbObjects + " objects "); int k = 0; while (l.HasNext()) { object o = l.Next(); if (k % 9999 == 0) { Println(((SimpleObject)o).GetName()); } k++; } // println("end of real get "); t5 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); Println("select " + (t5 - t3) + " - " + (t5 - t4)); so = null; k = 0; l.Reset(); while (l.HasNext()) { so = (SimpleObject)l.Next(); so.SetName(so.GetName() + " updated"); odb.Store(so); if (k % 10000 == 0) { Println("update " + k); if (isLocal) { Println("after update : NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions ()); Println("After update=" + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy.GetEngine (odb).GetSession(true).GetCache().ToString()); } } k++; } if (isLocal) { Println("after update : NB WAs=" + engine.GetSession(true).GetTransaction().GetNumberOfWriteActions ()); } t6 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb.Close(); t7 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb = Open(OdbFileName); l = odb.GetObjects <SimpleObject>(false); t77 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); int j = 0; while (l.HasNext()) { so = (SimpleObject)l.Next(); AssertTrue(so.GetName().EndsWith("updated")); odb.Delete(so); if (j % 10000 == 0) { Println("delete " + j); } j++; } odb.Close(); t8 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); odb = Open(OdbFileName); AssertEquals(0, odb.GetObjects <SimpleObject>().Count); odb.Close(); DisplayResult("ODB " + TestSize + " SimpleObject objects ", t1, t2, t3, t4, t5, t6 , t7, t77, t8); }