/// <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> /// Create objects, then create index, then execute a select with index, then /// rebuild index e execute /// </summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestDeleteIndex() { string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB @base = Open(baseName); for (int i = 0; i < 2500; i++) { NeoDatis.Odb.Test.Index.IndexedObject3 io = new NeoDatis.Odb.Test.Index.IndexedObject3 (1 + i, 2, 3, "1" + i, "2", "3", new System.DateTime(2009, i, 1), new System.DateTime (), new System.DateTime()); @base.Store(io); } @base.Close(); @base = Open(baseName); NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3 )); string[] indexFields1 = new string[] { "i1", "i2", "i3" }; clazz.AddUniqueIndexOn("index1", indexFields1, true); @base.Close(); @base = Open(baseName); NeoDatis.Odb.Core.Transaction.ISession session = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy .GetEngine(@base).GetSession(true); NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = session.GetStorageEngine ().GetSession(true).GetMetaModel(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = metaModel.GetClassInfo(typeof( NeoDatis.Odb.Test.Index.IndexedObject3).FullName, true); AssertEquals(1, ci.GetNumberOfIndexes()); AssertEquals(ci.GetIndex(0).GetName(), "index1"); AssertEquals(3, ci.GetIndex(0).GetAttributeIds().Length); AssertEquals(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex.Enabled, ci.GetIndex (0).GetStatus()); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Index.IndexedObject3), NeoDatis.Odb.Core.Query.Criteria.Where .And().Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("i1", 10)).Add(NeoDatis.Odb.Core.Query.Criteria.Where .Equal("i2", 2)).Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("i3", 3))); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Index.IndexedObject3> objects = @base.GetObjects (q); AssertEquals(true, q.GetExecutionPlan().UseIndex()); @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3)).DeleteIndex ("index1", true); @base.Close(); @base = Open(baseName); objects = @base.GetObjects(q); AssertEquals(false, q.GetExecutionPlan().UseIndex()); @base.Close(); DeleteBase(baseName); }
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); }
/// <exception cref="System.IO.IOException"></exception> /// <exception cref="System.Exception"></exception> public virtual void T2estBigFileWithOdbSelect() { // OdbConfiguration.setUseIndex(false); string baseName = "big-file.neodatis"; NeoDatis.Odb.ODB odb = null; // Thread.sleep(20000); try { long start = Sharpen.Runtime.CurrentTimeMillis(); odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "login10000")); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.VO.Login.Function> functions = odb.GetObjects (q, true, 0, 1); System.Console.Out.WriteLine(q.GetExecutionPlan().GetDetails()); System.Console.Out.WriteLine(functions.Count); Println(Sharpen.Runtime.CurrentTimeMillis() - start + "ms"); } finally { if (odb != null) { odb.Close(); } } }
/// <summary> /// Opens a connection C1, then create the index in another connection C2 and /// then stores the object in connection C1 /// </summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestCreateIndexInOtherConnectionNoCommit2() { if (isLocal || !testNewFeature) { return; } string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB odb1 = Open(baseName); NeoDatis.Odb.ODB odb2 = Open(baseName); NeoDatis.Odb.ClassRepresentation clazz = odb2.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3 )); string[] indexFields1 = new string[] { "i1" }; clazz.AddUniqueIndexOn("index1", indexFields1, true); for (int i = 0; i < 10; i++) { NeoDatis.Odb.Test.Index.IndexedObject3 io = new NeoDatis.Odb.Test.Index.IndexedObject3 (1 + i, 2, 3, "1" + i, "2", "3", new System.DateTime(2009, i, 1), new System.DateTime (), new System.DateTime()); odb1.Store(io); } odb1.Close(); odb2.Close(); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Index.IndexedObject3), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("i1", 1)); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Index.IndexedObject3> iis = odb.GetObjects (q); odb.Close(); AssertEquals(1, iis.Count); AssertTrue(q.GetExecutionPlan().UseIndex()); DeleteBase(baseName); }
/// <exception cref="System.IO.IOException"></exception> /// <exception cref="System.Exception"></exception> public virtual void T2estBigFileWithOdbSelect() { // OdbConfiguration.setUseIndex(false); string baseName = "big-file.neodatis"; NeoDatis.Odb.ODB odb = null; // Thread.sleep(20000); try { long start = Sharpen.Runtime.CurrentTimeMillis(); odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "login10000")); NeoDatis.Odb.Objects<NeoDatis.Odb.Test.VO.Login.Function> functions = odb.GetObjects (q, true, 0, 1); System.Console.Out.WriteLine(q.GetExecutionPlan().GetDetails()); System.Console.Out.WriteLine(functions.Count); Println(Sharpen.Runtime.CurrentTimeMillis() - start + "ms"); } finally { if (odb != null) { odb.Close(); } } }
/// <summary>Test index creation without commit</summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestCreateIndexWithoutCommit() { string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB @base = Open(baseName); NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3 )); string[] indexFields1 = new string[] { "i1" }; clazz.AddUniqueIndexOn("index1", indexFields1, true); for (int i = 0; i < 10; i++) { NeoDatis.Odb.Test.Index.IndexedObject3 io = new NeoDatis.Odb.Test.Index.IndexedObject3 (1 + i, 2, 3, "1" + i, "2", "3", new System.DateTime(2009, i, 1), new System.DateTime (), new System.DateTime()); @base.Store(io); } @base.Close(); @base = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Index.IndexedObject3), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("i1", 1)); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Index.IndexedObject3> iis = @base.GetObjects (q); @base.Close(); AssertEquals(1, iis.Count); AssertTrue(q.GetExecutionPlan().UseIndex()); DeleteBase(baseName); }
/// <exception cref="System.Exception"></exception> public virtual void T1estA() { NeoDatis.Odb.ODB odb = Open("perfOValuesVsCriteriaIndex"); NeoDatis.Odb.OdbConfiguration.MonitorMemory(true); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.User2), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "user1999999")); NeoDatis.Odb.Objects objects = odb.GetObjects(q, false); Println(objects.Count); System.Console.Out.WriteLine(q.GetExecutionPlan().GetDetails()); AssertEquals(1, objects.Count); objects = odb.GetObjects(q, false); Println(objects.Count); System.Console.Out.WriteLine(q.GetExecutionPlan().GetDetails()); AssertEquals(1, objects.Count); odb.Close(); }
public virtual void Test2() { Println("************START OF TEST2***************"); 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); 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("index-object"); 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(); 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("index-object"); Println("************END OF TEST2***************"); }
/// <exception cref="System.Exception"></exception> public virtual void T1estA() { NeoDatis.Odb.ODB odb = Open("perfOValuesVsCriteria"); NeoDatis.Odb.OdbConfiguration.MonitorMemory(true); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.User2)); NeoDatis.Odb.Objects objects = odb.GetObjects(q, false); Println(objects.Count); System.Console.Out.WriteLine(q.GetExecutionPlan().GetDetails()); AssertEquals(2000000, objects.Count); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void T1est() { NeoDatis.Odb.ODB odb = Open("perfOValuesVsCriteria"); NeoDatis.Odb.OdbConfiguration.MonitorMemory(true); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.User2)); System.Decimal b = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.User2))); Println(b); System.Console.Out.WriteLine(q.GetExecutionPlan().GetDetails()); AssertEquals(new System.Decimal("500000"), b); odb.Close(); }
/// <summary>Test index creation without commit</summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestCreateIndexWithoutCommit() { string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB @base = Open(baseName); NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3 )); string[] indexFields1 = new string[] { "i1" }; clazz.AddUniqueIndexOn("index1", indexFields1, true); for (int i = 0; i < 10; i++) { NeoDatis.Odb.Test.Index.IndexedObject3 io = new NeoDatis.Odb.Test.Index.IndexedObject3 (1 + i, 2, 3, "1" + i, "2", "3", new System.DateTime(2009, i, 1), new System.DateTime (), new System.DateTime()); @base.Store(io); } @base.Close(); @base = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Index.IndexedObject3), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("i1", 1)); NeoDatis.Odb.Objects<NeoDatis.Odb.Test.Index.IndexedObject3> iis = @base.GetObjects (q); @base.Close(); AssertEquals(1, iis.Count); AssertTrue(q.GetExecutionPlan().UseIndex()); DeleteBase(baseName); }
/// <summary> /// Create objects, then create index, then execute a select with index, then /// rebuild index e execute /// </summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestDeleteIndex() { string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB @base = Open(baseName); for (int i = 0; i < 2500; i++) { NeoDatis.Odb.Test.Index.IndexedObject3 io = new NeoDatis.Odb.Test.Index.IndexedObject3 (1 + i, 2, 3, "1" + i, "2", "3", new System.DateTime(2009, i, 1), new System.DateTime (), new System.DateTime()); @base.Store(io); } @base.Close(); @base = Open(baseName); NeoDatis.Odb.ClassRepresentation clazz = @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3 )); string[] indexFields1 = new string[] { "i1", "i2", "i3" }; clazz.AddUniqueIndexOn("index1", indexFields1, true); @base.Close(); @base = Open(baseName); NeoDatis.Odb.Core.Transaction.ISession session = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.Dummy .GetEngine(@base).GetSession(true); NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = session.GetStorageEngine ().GetSession(true).GetMetaModel(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = metaModel.GetClassInfo(typeof( NeoDatis.Odb.Test.Index.IndexedObject3).FullName, true); AssertEquals(1, ci.GetNumberOfIndexes()); AssertEquals(ci.GetIndex(0).GetName(), "index1"); AssertEquals(3, ci.GetIndex(0).GetAttributeIds().Length); AssertEquals(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex.Enabled, ci.GetIndex (0).GetStatus()); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Index.IndexedObject3), NeoDatis.Odb.Core.Query.Criteria.Where .And().Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("i1", 10)).Add(NeoDatis.Odb.Core.Query.Criteria.Where .Equal("i2", 2)).Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("i3", 3))); NeoDatis.Odb.Objects<NeoDatis.Odb.Test.Index.IndexedObject3> objects = @base.GetObjects (q); AssertEquals(true, q.GetExecutionPlan().UseIndex()); @base.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3)).DeleteIndex ("index1", true); @base.Close(); @base = Open(baseName); objects = @base.GetObjects(q); AssertEquals(false, q.GetExecutionPlan().UseIndex()); @base.Close(); DeleteBase(baseName); }
/// <summary> /// Opens a connection C1, then create the index in another connection C2 and /// then stores the object in connection C1 /// </summary> /// <exception cref="System.Exception">System.Exception</exception> public virtual void TestCreateIndexInOtherConnectionNoCommit2() { if (isLocal || !testNewFeature) { return; } string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB odb1 = Open(baseName); NeoDatis.Odb.ODB odb2 = Open(baseName); NeoDatis.Odb.ClassRepresentation clazz = odb2.GetClassRepresentation(typeof(NeoDatis.Odb.Test.Index.IndexedObject3 )); string[] indexFields1 = new string[] { "i1" }; clazz.AddUniqueIndexOn("index1", indexFields1, true); for (int i = 0; i < 10; i++) { NeoDatis.Odb.Test.Index.IndexedObject3 io = new NeoDatis.Odb.Test.Index.IndexedObject3 (1 + i, 2, 3, "1" + i, "2", "3", new System.DateTime(2009, i, 1), new System.DateTime (), new System.DateTime()); odb1.Store(io); } odb1.Close(); odb2.Close(); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Index.IndexedObject3), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("i1", 1)); NeoDatis.Odb.Objects<NeoDatis.Odb.Test.Index.IndexedObject3> iis = odb.GetObjects (q); odb.Close(); AssertEquals(1, iis.Count); AssertTrue(q.GetExecutionPlan().UseIndex()); DeleteBase(baseName); }
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 { } }
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(); }
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); } }
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); }
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); } }