/// <exception cref="System.Exception"></exception> public virtual void Test6updateChangingKeyValue() { // to monitor in place updates NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates(); NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "test2")); NeoDatis.Odb.Objects l = odb.GetObjects(query); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); dictionnary.GetMap().Add("f1", "changed function"); odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )odb.GetObjects(query).GetFirst(); AssertEquals("changed function", dic.GetMap()["f1"]); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test6updateDecreasingSize() { NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "test2")); NeoDatis.Odb.Objects l = odb.GetObjects(query); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); int mapSize = dictionnary.GetMap().Count; dictionnary.GetMap().Remove("f1"); odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )odb.GetObjects(query).GetFirst(); AssertEquals(mapSize - 1, dic.GetMap().Count); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test5updateIncreasingSize() { NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "test2")); NeoDatis.Odb.Objects l = odb.GetObjects(query); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); dictionnary.SetMap(null); odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )odb.GetObjects(query).GetFirst(); AssertNull(dic.GetMap()); odb.Close(); odb = Open("map.neodatis"); dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)odb.GetObjects(query). GetFirst(); dic.AddEntry("olivier", "Smadja"); odb.Store(dic); odb.Close(); odb = Open("map.neodatis"); dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)odb.GetObjects(query). GetFirst(); AssertNotNull(dic.GetMap()); AssertEquals("Smadja", dic.GetMap()["olivier"]); odb.Close(); }
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(); } } }
/// <exception cref="System.Exception"></exception> public virtual void TestReuse() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); System.Collections.Generic.IList <NeoDatis.Odb.Test.VO.Login.Profile> profiles = new System.Collections.Generic.List <NeoDatis.Odb.Test.VO.Login.Profile>(); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p1", new NeoDatis.Odb.Test.VO.Login.Function ("f1"))); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p2", new NeoDatis.Odb.Test.VO.Login.Function ("f2"))); NeoDatis.Odb.Test.Query.Criteria.ClassB cb = new NeoDatis.Odb.Test.Query.Criteria.ClassB ("name", profiles); odb.Store(cb); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Profile p = (NeoDatis.Odb.Test.VO.Login.Profile)odb.GetObjects (typeof(NeoDatis.Odb.Test.VO.Login.Profile)).GetFirst(); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = odb.CriteriaQuery(typeof( NeoDatis.Odb.Test.Query.Criteria.ClassB), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("profiles", p)); NeoDatis.Odb.Impl.Core.Query.Criteria.EqualCriterion ec = (NeoDatis.Odb.Impl.Core.Query.Criteria.EqualCriterion )query.GetCriteria(); try { NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Query.Criteria.ClassB> l = odb.GetObjects( query); } catch (System.Exception e) { AssertTrue(NeoDatis.Tool.Wrappers.OdbString.ExceptionToString(e, true).IndexOf("1063" ) != -1); } odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test2() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); System.Collections.Generic.IList <NeoDatis.Odb.Test.VO.Login.Profile> profiles = new System.Collections.Generic.List <NeoDatis.Odb.Test.VO.Login.Profile>(); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p1", new NeoDatis.Odb.Test.VO.Login.Function ("f1"))); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p2", new NeoDatis.Odb.Test.VO.Login.Function ("f2"))); NeoDatis.Odb.Test.Query.Criteria.ClassB cb = new NeoDatis.Odb.Test.Query.Criteria.ClassB ("name", profiles); odb.Store(cb); odb.Close(); odb = Open(baseName); NeoDatis.Odb.Test.VO.Login.Profile p = (NeoDatis.Odb.Test.VO.Login.Profile)odb.GetObjects (typeof(NeoDatis.Odb.Test.VO.Login.Profile)).GetFirst(); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = odb.CriteriaQuery(typeof( NeoDatis.Odb.Test.Query.Criteria.ClassB), NeoDatis.Odb.Core.Query.Criteria.Where .Contain("profiles", p)); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Query.Criteria.ClassB> l = odb.GetObjects( query); odb.Close(); AssertEquals(1, l.Count); }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); System.Collections.Generic.IList <NeoDatis.Odb.Test.VO.Login.Profile> profiles = new System.Collections.Generic.List <NeoDatis.Odb.Test.VO.Login.Profile>(); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p1", new NeoDatis.Odb.Test.VO.Login.Function ("f1"))); profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p2", new NeoDatis.Odb.Test.VO.Login.Function ("f2"))); NeoDatis.Odb.Test.Query.Criteria.ClassB cb = new NeoDatis.Odb.Test.Query.Criteria.ClassB ("name", profiles); odb.Store(cb); odb.Close(); odb = Open(baseName); // this object is not known y NeoDatis so the query will not return anything NeoDatis.Odb.Test.VO.Login.Profile p = new NeoDatis.Odb.Test.VO.Login.Profile("p1" , (System.Collections.IList)null); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = odb.CriteriaQuery(typeof( NeoDatis.Odb.Test.Query.Criteria.ClassB), NeoDatis.Odb.Core.Query.Criteria.Where .Contain("profiles", p)); NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Query.Criteria.ClassB> l = odb.GetObjects( query); odb.Close(); AssertEquals(0, l.Count); }
/// <exception cref="System.Exception"></exception> public virtual void Test4Sort() { int d = NeoDatis.Odb.OdbConfiguration.GetDefaultIndexBTreeDegree(); try { NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(40); NeoDatis.Odb.ODB odb = Open("criteria.neodatis"); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery aq = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Not(NeoDatis.Odb.Core.Query.Criteria.Where.Or().Add(NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "function 2")).Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("name" , "function 3")))); aq.OrderByDesc("name"); // aq.orderByAsc("name"); NeoDatis.Odb.Objects l = odb.GetObjects(aq, true, -1, -1); AssertEquals(48, l.Count); NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)l.GetFirst (); AssertEquals("function 9", f.GetName()); odb.Close(); } finally { NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(d); } }
public virtual void Test1() { string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = null; int k = 10; long t1 = OdbTime.GetCurrentTimeInMs(); odb = Open(baseName); for (int i = 0; i < k; i++) { odb.Store(new NeoDatis.Odb.Test.List.User("john" + (k - i), "*****@*****.**", "ny 875" , k - i + 1, new System.DateTime(t1 - i * 1000), i % 2 == 0)); odb.Store(new NeoDatis.Odb.Test.List.User("john" + (k - i), "*****@*****.**", "ny 875" , k - i, new System.DateTime(t1 - i * 1000), (i + 1) % 2 == 0)); } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.List.User)).OrderByAsc("name,id"); NeoDatis.Odb.Objects<NeoDatis.Odb.Test.List.User> users = odb.GetObjects<User>(q); odb.Close(); if (k < 11) { //NeoDatis.Tool.DisplayUtility.Display("test1", users); } NeoDatis.Odb.Test.List.User user = users.GetFirst(); AssertTrue(user.GetName().StartsWith("john1")); AssertEquals(1, user.GetId()); }
/// <exception cref="System.Exception"></exception> public virtual void Test4Sort() { int d = NeoDatis.Odb.OdbConfiguration.GetDefaultIndexBTreeDegree(); try { NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(40); NeoDatis.Odb.ODB odb = Open("criteria.neodatis"); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery aq = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Not(NeoDatis.Odb.Core.Query.Criteria.Where.Or().Add(NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "function 2")).Add(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("name" , "function 3")))); aq.OrderByDesc("name"); // aq.orderByAsc("name"); NeoDatis.Odb.Objects l = odb.GetObjects(aq, true, -1, -1); AssertEquals(48, l.Count); NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)l.GetFirst (); AssertEquals("function 9", f.GetName()); odb.Close(); } finally { NeoDatis.Odb.OdbConfiguration.SetDefaultIndexBTreeDegree(d); } }
public CriteriaQueryExecutionPlan(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo classInfo, NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query) { this.classInfo = classInfo; this.query = query; this.query.SetExecutionPlan(this); Init(); }
public CriteriaQueryExecutionPlan(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo classInfo, NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query) { this.classInfo = classInfo; this.query = query; this.query.SetExecutionPlan(this); Init(); }
/// <exception cref="System.Exception"></exception> public virtual void TestLike2() { NeoDatis.Odb.ODB odb = Open("criteria.neodatis"); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery aq = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Like("name", "FuNc%")); aq.OrderByDesc("name"); NeoDatis.Odb.Objects l = odb.GetObjects(aq, true, -1, -1); AssertEquals(0, l.Count); odb.Close(); }
/// <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(); }
/// <exception cref="System.Exception"></exception> public virtual void Test2() { NeoDatis.Odb.ODB odb = Open("criteria.neodatis"); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery aq = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Not(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("name", "function 2"))); NeoDatis.Odb.Objects l = odb.GetObjects(aq, true, -1, -1); AssertEquals(49, l.Count); NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)l.GetFirst (); AssertEquals("function 0", f.GetName()); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test2() { NeoDatis.Odb.ODB odb = Open("criteria.neodatis"); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery aq = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where .Not(NeoDatis.Odb.Core.Query.Criteria.Where.Equal("name", "function 2"))); NeoDatis.Odb.Objects l = odb.GetObjects(aq, true, -1, -1); AssertEquals(49, l.Count); NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)l.GetFirst (); AssertEquals("function 0", f.GetName()); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test2() { NeoDatis.Odb.ODB odb = Open("map.neodatis"); NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery aq = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "test2")); l = odb.GetObjects(aq); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); AssertEquals(new NeoDatis.Odb.Test.VO.Login.Function("function2").GetName(), ((NeoDatis.Odb.Test.VO.Login.Function )dictionnary.Get("f2")).GetName()); odb.Close(); }
public override long Count(NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query ) { if (isClosed) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.OdbIsClosed .AddParameter(baseIdentification.GetIdentification())); } NeoDatis.Odb.Core.Query.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery (query).Count("count"); NeoDatis.Odb.Values values = GetValues(q, -1, -1); long count = (long)values.NextValues().GetByIndex(0); return(count); }
/// <exception cref="System.Exception"></exception> public virtual void Test2() { NeoDatis.Odb.ODB odb = Open("map.neodatis"); NeoDatis.Odb.Objects l = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery aq = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "test2")); l = odb.GetObjects(aq); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); AssertEquals(new NeoDatis.Odb.Test.VO.Login.Function("function2").GetName(), ((NeoDatis.Odb.Test.VO.Login.Function )dictionnary.Get("f2")).GetName()); odb.Close(); }
public virtual void TestNullRelation() { DeleteBase("null-rel.neodatis"); NeoDatis.Odb.ODB odb = Open("null-rel.neodatis"); odb.Store(new NeoDatis.Odb.Test.Query.Criteria.Class2()); odb.Close(); odb = Open("null-rel.neodatis"); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Query.Criteria.Class2), NeoDatis.Odb.Core.Query.Criteria.Where .IsNull("class1.name")); NeoDatis.Odb.Objects<Class2> os = odb.GetObjects<Class2>(q); odb.Close(); AssertEquals(1, os.Count); NeoDatis.Odb.Test.Query.Criteria.Class2 c2 = (NeoDatis.Odb.Test.Query.Criteria.Class2 )os.GetFirst(); AssertEquals(null, c2.GetClass1()); }
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.IO.IOException"></exception> /// <exception cref="System.Exception"></exception> public virtual void RunJava() { NeoDatis.Odb.ODB odb = null; NeoDatis.Odb.Test.ODBTest test = new NeoDatis.Odb.Test.ODBTest(); try { test.DeleteBase("mydb7.neodatis"); // Open the database odb = test.Open("mydb7.neodatis"); long start0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); int nRecords = 100000; for (int i = 0; i < nRecords; i++) { NeoDatis.Odb.Test.Dotnet.AA ao = new NeoDatis.Odb.Test.Dotnet.AA(); ao.ccc = "csdcsdc"; ao.ww = i; odb.Store(ao); } long end0 = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Dotnet.AA)); query.OrderByAsc("ww"); long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.Objects object12 = odb.GetObjects(query, false); while (object12.HasNext()) { NeoDatis.Odb.Test.Dotnet.AA s = (NeoDatis.Odb.Test.Dotnet.AA)object12.Next(); int id = s.ww; } // println(id); long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); test.Println("Time=" + (end - start) + " / " + (end - start0) + " / " + (end0 - start0 )); } finally { if (odb != null) { // Close the database odb.Close(); } } }
/// <exception cref="System.Exception"></exception> public virtual void Test1() { DeleteBase("multi"); NeoDatis.Odb.ODB odb = Open("multi"); odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("dog", "M", "my dog")); odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("cat", "F", "my cat")); odb.Store(new NeoDatis.Odb.Test.VO.Human.Man("Joe")); odb.Store(new NeoDatis.Odb.Test.VO.Human.Woman("Karine")); odb.Close(); odb = Open("multi"); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(object)); q.SetPolymorphic(true); NeoDatis.Odb.Objects os = odb.GetObjects(q); Println(os); odb.Close(); AssertEquals(4, os.Count); DeleteBase("multi"); }
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"); } }
/// <exception cref="System.Exception"></exception> public virtual void Test6updateChangingKeyValue() { // to monitor in place updates NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.AbstractObjectWriter.ResetNbUpdates(); NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "test2")); NeoDatis.Odb.Objects l = odb.GetObjects(query); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); dictionnary.GetMap().Add("f1", "changed function"); odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )odb.GetObjects(query).GetFirst(); AssertEquals("changed function", dic.GetMap()["f1"]); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test6updateDecreasingSize() { NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "test2")); NeoDatis.Odb.Objects l = odb.GetObjects(query); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); int mapSize = dictionnary.GetMap().Count; dictionnary.GetMap().Remove("f1"); odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )odb.GetObjects(query).GetFirst(); AssertEquals(mapSize - 1, dic.GetMap().Count); odb.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test5updateIncreasingSize() { NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "test2")); NeoDatis.Odb.Objects l = odb.GetObjects(query); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); dictionnary.SetMap(null); odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )odb.GetObjects(query).GetFirst(); AssertNull(dic.GetMap()); odb.Close(); odb = Open("map.neodatis"); dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)odb.GetObjects(query). GetFirst(); dic.AddEntry("olivier", "Smadja"); odb.Store(dic); odb.Close(); odb = Open("map.neodatis"); dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)odb.GetObjects(query). GetFirst(); AssertNotNull(dic.GetMap()); AssertEquals("Smadja", dic.GetMap()["olivier"]); odb.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); } }
/// <exception cref="System.Exception"></exception> public virtual void Test6() { DeleteBase("multi"); NeoDatis.Odb.ODB odb = Open("multi"); odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("dog", "M", "my dog")); odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("cat", "F", "my cat")); odb.Store(new NeoDatis.Odb.Test.VO.Human.Man("Joe")); odb.Store(new NeoDatis.Odb.Test.VO.Human.Woman("Karine")); odb.Close(); odb = Open("multi"); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(object)); q.SetPolymorphic(true); System.Decimal nb = odb.Count(q); Println(nb); odb.Close(); AssertEquals(new System.Decimal("4"), nb); DeleteBase("multi"); }
/// <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 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); } }
public virtual void Test7() { int size = isLocal ? 3000 : 300; string baseName = GetBaseName(); NeoDatis.Odb.ODB odb = Open(baseName); for (int i = 0; i < size; i++) { odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("dog", "M", "my dog")); odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("cat", "F", "my cat")); odb.Store(new NeoDatis.Odb.Test.VO.Human.Man("Joe" + i)); odb.Store(new NeoDatis.Odb.Test.VO.Human.Woman("Karine" + i)); } odb.Close(); odb = Open(baseName); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(object)); q.SetPolymorphic(true); System.Decimal nb = odb.Count(q); Println(nb); odb.Close(); AssertEquals(new System.Decimal(4 * size), nb); DeleteBase(baseName); }
public ValuesCriteriaQueryExecutor(NeoDatis.Odb.Core.Query.IQuery query, NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine) : base(query, engine) { criteriaQuery = (NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery)query; }
/// <exception cref="System.Exception"></exception> public virtual void Test8() { int size = isLocal ? 30000 : 3000; DeleteBase("multi"); NeoDatis.Odb.ODB odb = Open("multi"); for (int i = 0; i < size; i++) { odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("dog" + i, "M", "my dog" + i)); odb.Store(new NeoDatis.Odb.Test.VO.Human.Animal("cat" + i, "F", "my cat" + i)); odb.Store(new NeoDatis.Odb.Test.VO.Human.Man("Joe" + i)); odb.Store(new NeoDatis.Odb.Test.VO.Human.Woman("Karine" + i)); } odb.Close(); odb = Open("multi"); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(object), NeoDatis.Odb.Core.Query.Criteria.Where.Equal("specie", "man")); q.SetPolymorphic(true); System.Decimal nb = odb.Count(q); Println(nb); odb.Close(); AssertEquals(new System.Decimal(string.Empty + 1 * size), nb); DeleteBase("multi"); }
/// <exception cref="System.Exception"></exception> public virtual void Test4() { NeoDatis.Odb.ODB odb = Open("map.neodatis"); long n = odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery(typeof( NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary))); NeoDatis.Odb.Core.Query.IQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("name", "test2")); NeoDatis.Odb.Objects l = odb.GetObjects(query); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dictionnary = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )l.GetFirst(); dictionnary.SetMap(null); odb.Store(dictionnary); odb.Close(); odb = Open("map.neodatis"); AssertEquals(n, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary)))); NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary dic = (NeoDatis.Odb.Test.VO.Arraycollectionmap.Dictionnary )odb.GetObjects(query).GetFirst(); AssertEquals(null, dic.GetMap()); odb.Close(); }
public virtual void Test6() { int sublistSize = 400; if (!isLocal && !useSameVmOptimization) { sublistSize = 40; } string baseName = GetBaseName(); DeleteBase(baseName); NeoDatis.Odb.ODB odb = Open(baseName); NeoDatis.Odb.Test.Query.Values.Handler handler = new NeoDatis.Odb.Test.Query.Values.Handler (); for (int i = 0; i < sublistSize; i++) { handler.AddParameter(new NeoDatis.Odb.Test.Query.Values.Parameter("test " + i, "value " + i)); } odb.Store(handler); odb.Close(); odb = Open("valuesSubList3"); long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.Core.Query.IQuery q = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Query.Values.Handler)); NeoDatis.Odb.Objects objects = odb.GetObjects(q); long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs(); NeoDatis.Odb.Test.Query.Values.Handler h = (NeoDatis.Odb.Test.Query.Values.Handler )objects.GetFirst(); NeoDatis.Odb.Test.Query.Values.Parameter parameter = (NeoDatis.Odb.Test.Query.Values.Parameter )h.GetListOfParameters()[0]; AssertEquals("value 0", parameter.GetValue()); NeoDatis.Odb.OID oid = odb.GetObjectId(parameter); AssertNotNull(oid); 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.Exception"></exception> private void CheckCarRetrieval() { NeoDatis.Odb.Objects cars = odb.GetObjects(typeof(NeoDatis.Odb.Test.Instantiationhelper.Car )); AssertEquals(1, cars.Count); NeoDatis.Odb.Test.Instantiationhelper.Car car = (NeoDatis.Odb.Test.Instantiationhelper.Car )cars.GetFirst(); AssertEquals(car.GetModel(), "Ranger"); AssertEquals(car.GetYear(), 2006); NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery (typeof(NeoDatis.Odb.Test.Instantiationhelper.Car), NeoDatis.Odb.Core.Query.Criteria.Where .Equal("model", "Ranger")); cars = odb.GetObjects(query); car = (NeoDatis.Odb.Test.Instantiationhelper.Car)cars.GetFirst(); AssertEquals(car.GetModel(), "Ranger"); }
/// <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); }
public override void PrepareQuery() { criteriaQuery = (NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery)query; criteriaQuery.SetStorageEngine(storageEngine); involvedFields = criteriaQuery.GetAllInvolvedFields(); }