Esempio n. 1
0
        public virtual void Test10()
        {
            DeleteBase("valuesA2");
            NeoDatis.Odb.ODB        odb = Open("valuesA2");
            NeoDatis.Tool.StopWatch t   = new NeoDatis.Tool.StopWatch();
            t.Start();
            int  size = 1000;
            long sum  = 0;

            for (int i = 0; i < size; i++)
            {
                NeoDatis.Odb.Test.VO.Attribute.TestClass tc1 = new NeoDatis.Odb.Test.VO.Attribute.TestClass
                                                                   ();
                tc1.SetInt1(i);
                odb.Store(tc1);
                sum += i;
            }
            odb.Close();
            t.End();
            Println(" time for insert = " + t.GetDurationInMiliseconds());
            odb = Open("valuesA2");
            t.Start();
            NeoDatis.Odb.Core.Query.Values.ICustomQueryFieldAction custom = new NeoDatis.Odb.Test.Query.Values.TestCustomQueryFieldAction
                                                                                ();
            NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                           (typeof(NeoDatis.Odb.Test.VO.Attribute.TestClass)).Custom("int1", "custom of int1"
                                                                                                                     , custom));
            t.End();
            NeoDatis.Odb.ObjectValues ov = values.NextValues();
            System.Decimal            c  = (System.Decimal)ov.GetByAlias("custom of int1");
            Println(c);
            Println(" time for count = " + t.GetDurationInMiliseconds());
            odb.Close();
        }
Esempio n. 2
0
        public virtual void Test9()
        {
            DeleteBase("valuesA2");
            NeoDatis.Odb.ODB odb = Open("valuesA2");
            int  size            = isLocal ? 100000 : 1000;
            long sum             = 0;

            for (int i = 0; i < size; i++)
            {
                NeoDatis.Odb.Test.VO.Attribute.TestClass tc1 = new NeoDatis.Odb.Test.VO.Attribute.TestClass
                                                                   ();
                tc1.SetInt1(i);
                odb.Store(tc1);
                sum += i;
            }
            odb.Close();
            odb = Open("valuesA2");
            NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                           (typeof(NeoDatis.Odb.Test.VO.Attribute.TestClass)).Min("int1", "min of int1").Avg
                                                           ("int1", "avg of int1").Sum("int1", "sum of int1"));
            NeoDatis.Odb.ObjectValues ov   = values.NextValues();
            System.Decimal            min  = (System.Decimal)ov.GetByAlias("min of int1");
            System.Decimal            avg  = (System.Decimal)ov.GetByAlias("avg of int1");
            System.Decimal            bsum = (System.Decimal)ov.GetByAlias("sum of int1");
            Println(min);
            Println(avg);
            Println(bsum);
            odb.Close();
            AssertEquals(new System.Decimal(sum), bsum);
            AssertEquals(new System.Decimal(0), min);
            AssertEquals(bsum / 2, avg);
        }
Esempio n. 3
0
        public virtual void Test16()
        {
            DeleteBase("valuesA2");
            NeoDatis.Odb.ODB        odb = null;
            NeoDatis.Tool.StopWatch t   = new NeoDatis.Tool.StopWatch();
            int size = isLocal ? 10000 : 100;

            for (int j = 0; j < 10; j++)
            {
                t.Start();
                odb = Open("valuesA2");
                for (int i = 0; i < size; i++)
                {
                    NeoDatis.Odb.Test.VO.Attribute.TestClass tc1 = new NeoDatis.Odb.Test.VO.Attribute.TestClass
                                                                       ();
                    tc1.SetInt1(45);
                    odb.Store(tc1);
                }
                odb.Close();
                t.End();
                Println(" time for insert = " + t.GetDurationInMiliseconds());
            }
            odb = Open("valuesA2");
            t.Start();
            NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                           (typeof(NeoDatis.Odb.Test.VO.Attribute.TestClass)).Count("nb objects"));
            t.End();
            Println(values);
            Println(" time for count = " + t.GetDurationInMiliseconds());
            NeoDatis.Odb.ObjectValues ov = values.NextValues();
            odb.Close();
            AssertEquals(size * 10, ov.GetByAlias("nb objects"));
            AssertEquals(1, values.Count);
        }
Esempio n. 4
0
        public virtual void Test1()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            int size             = 10000;

            try
            {
                odb = Open(baseName);
                odb.GetClassRepresentation(typeof(NeoDatis.Odb.Test.VO.Login.Function)).AddIndexOn
                    ("index1", new string[] { "name" }, true);
                for (int i = 0; i < size; i++)
                {
                    odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("function " + i));
                }
                odb.Close();
                odb = Open(baseName);
                // build a value query to retrieve only the name of the function
                NeoDatis.Odb.Core.Query.IValuesQuery vq = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                              (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
                                                              .Equal("name", "function " + (size - 1))).Field("name");
                NeoDatis.Odb.Values values = odb.GetValues(vq);
                AssertEquals(1, values.Count);
                Println(vq.GetExecutionPlan().GetDetails());
                AssertEquals(true, vq.GetExecutionPlan().UseIndex());
            }
            finally
            {
                if (odb != null)
                {
                    odb.Close();
                }
            }
        }
Esempio n. 5
0
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.Exception"></exception>
        public virtual void Test11()
        {
            NeoDatis.Odb.ODB odb = NeoDatis.Odb.ODBFactory.Open("valuesSubList");
            NeoDatis.Odb.Test.Query.Values.Handler handler = new NeoDatis.Odb.Test.Query.Values.Handler
                                                                 ();
            for (int i = 0; i < 10; i++)
            {
                handler.AddParameter(new NeoDatis.Odb.Test.Query.Values.Parameter("test " + i, "value "
                                                                                  + i));
            }
            odb.Store(handler);
            odb.Close();
            odb = Open("valuesSubList");
            NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                           (typeof(NeoDatis.Odb.Test.Query.Values.Handler)).Field("parameters").Sublist("parameters"
                                                                                                                                        , "sub1", 1, 5, true).Sublist("parameters", "sub2", 1, 10).Size("parameters", "size"
                                                                                                                                                                                                        ));
            NeoDatis.Odb.ObjectValues ov = values.NextValues();
            // Retrieve Result values
            System.Collections.IList fulllist = (System.Collections.IList)ov.GetByAlias("parameters"
                                                                                        );
            long size = (long)ov.GetByAlias("size");

            System.Collections.IList sublist = (System.Collections.IList)ov.GetByAlias("sub1"
                                                                                       );
            odb.Close();
        }
Esempio n. 6
0
 public virtual void Test1()
 {
     DeleteBase("values2");
     NeoDatis.Odb.ODB odb = Open("values2");
     NeoDatis.Odb.Test.VO.Attribute.TestClass tc1 = new NeoDatis.Odb.Test.VO.Attribute.TestClass
                                                        ();
     tc1.SetInt1(45);
     odb.Store(tc1);
     NeoDatis.Odb.Test.VO.Attribute.TestClass tc2 = new NeoDatis.Odb.Test.VO.Attribute.TestClass
                                                        ();
     tc2.SetInt1(45);
     odb.Store(tc2);
     NeoDatis.Odb.Test.VO.Attribute.TestClass tc3 = new NeoDatis.Odb.Test.VO.Attribute.TestClass
                                                        ();
     tc3.SetInt1(46);
     odb.Store(tc3);
     odb.Close();
     odb = Open("values2");
     NeoDatis.Odb.Core.Query.IValuesQuery vq = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                   (typeof(NeoDatis.Odb.Test.VO.Attribute.TestClass)).Sum("int1", "sum of int1").GroupBy
                                                   ("int1");
     vq.OrderByAsc("int1");
     NeoDatis.Odb.Values values = odb.GetValues(vq);
     AssertEquals(2, values.Count);
     Println(values);
     NeoDatis.Odb.ObjectValues ov = values.NextValues();
     AssertEquals(System.Decimal.ValueOf(90), ov.GetByAlias("sum of int1"));
     ov = values.NextValues();
     AssertEquals(System.Decimal.ValueOf(46), ov.GetByAlias("sum of int1"));
     odb.Close();
     AssertEquals(2, values.Count);
 }
 public GetObjectValuesMessageResponse(string baseId, string connectionId, NeoDatis.Odb.Values
                                       values, NeoDatis.Odb.Core.Query.Execution.IQueryExecutionPlan queryExecutionPlan
                                       ) : base(NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Command.GetObjectValues,
                                                baseId, connectionId)
 {
     this.values = values;
     this.plan   = queryExecutionPlan;
 }
		public GetObjectValuesMessageResponse(string baseId, string connectionId, NeoDatis.Odb.Values
			 values, NeoDatis.Odb.Core.Query.Execution.IQueryExecutionPlan queryExecutionPlan
			) : base(NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Command.GetObjectValues, 
			baseId, connectionId)
		{
			this.values = values;
			this.plan = queryExecutionPlan;
		}
Esempio n. 9
0
        public virtual void Test4()
        {
            DeleteBase("sublist4");
            NeoDatis.Odb.ODB odb = Open("sublist4");
            int i = 0;

            System.Collections.IList functions1 = new System.Collections.ArrayList();
            for (i = 0; i < 30; i++)
            {
                functions1.Add(new NeoDatis.Odb.Test.VO.Login.Function("f1-" + i));
            }
            System.Collections.IList functions2 = new System.Collections.ArrayList();
            for (i = 0; i < 60; i++)
            {
                functions2.Add(new NeoDatis.Odb.Test.VO.Login.Function("f2-" + i));
            }
            System.Collections.IList functions3 = new System.Collections.ArrayList();
            for (i = 0; i < 90; i++)
            {
                functions3.Add(new NeoDatis.Odb.Test.VO.Login.Function("f3-" + i));
            }
            NeoDatis.Odb.Test.VO.Login.User user1 = new NeoDatis.Odb.Test.VO.Login.User("User1"
                                                                                        , "*****@*****.**", new NeoDatis.Odb.Test.VO.Login.Profile("profile1", functions1
                                                                                                                                                      ));
            NeoDatis.Odb.Test.VO.Login.User user2 = new NeoDatis.Odb.Test.VO.Login.User("User2"
                                                                                        , "*****@*****.**", new NeoDatis.Odb.Test.VO.Login.Profile("profile2", functions2
                                                                                                                                                      ));
            NeoDatis.Odb.Test.VO.Login.User user3 = new NeoDatis.Odb.Test.VO.Login.User("User3"
                                                                                        , "*****@*****.**", new NeoDatis.Odb.Test.VO.Login.Profile("profile3", functions3
                                                                                                                                                      ));
            odb.Store(user1);
            odb.Store(user2);
            odb.Store(user3);
            odb.Close();
            odb = Open("sublist4");
            NeoDatis.Odb.Test.VO.Login.User u = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjects
                                                    (typeof(NeoDatis.Odb.Test.VO.Login.User)).GetFirst();
            System.Console.Out.WriteLine(u);
            NeoDatis.Odb.Core.Query.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                         (typeof(NeoDatis.Odb.Test.VO.Login.Profile)).Field("name").Sublist("functions",
                                                                                                                            1, 2, false).Size("functions", "fsize");
            NeoDatis.Odb.Values v = odb.GetValues(q);
            i = 0;
            while (v.HasNext())
            {
                NeoDatis.Odb.ObjectValues ov = v.NextValues();
                string profileName           = (string)ov.GetByAlias("name");
                Println(profileName);
                AssertEquals("profile" + (i + 1), profileName);
                AssertEquals(System.Convert.ToInt64(30 * (i + 1)), ov.GetByAlias("fsize"));
                System.Collections.IList l = (System.Collections.IList)ov.GetByAlias("functions");
                Println(l);
                AssertEquals(2, l.Count);
                i++;
            }
            odb.Close();
        }
Esempio n. 10
0
 // Nothing to do
 /// <exception cref="System.Exception"></exception>
 public static void Main2(string[] args)
 {
     NeoDatis.Odb.ODB odb = null;
     NeoDatis.Odb.Impl.Core.Query.Values.CustomQueryFieldAction customAction = new NeoDatis.Odb.Test.Query.Values.TestCustomQueryFieldAction
                                                                                   ();
     NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                    (typeof(NeoDatis.Odb.Test.Query.Values.Users)).Custom("nbLogins", "nb logged users"
                                                                                                          , customAction).Field("name"));
 }
Esempio n. 11
0
 public virtual long Count(NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                           query)
 {
     NeoDatis.Odb.Core.Query.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                  (query).Count("count");
     q.SetPolymorphic(query.IsPolymorphic());
     NeoDatis.Odb.Values values = storageEngine.GetValues(q, -1, -1);
     System.Decimal      count  = (System.Decimal)values.NextValues().GetByIndex(0);
     return(System.Decimal.ToInt64(count));
 }
 /// <exception cref="System.Exception"></exception>
 public virtual void T1est1()
 {
     NeoDatis.Odb.ODB odb = Open("perfOValuesVsCriteria");
     NeoDatis.Odb.OdbConfiguration.MonitorMemory(true);
     NeoDatis.Odb.Core.Query.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                  (typeof(NeoDatis.Odb.Test.VO.Login.User2), NeoDatis.Odb.Core.Query.Criteria.Where
                                                  .Equal("nbLogins", 100)).Field("name");
     NeoDatis.Odb.Values v = odb.GetValues(q);
     Println(v.Count);
     System.Console.Out.WriteLine(q.GetExecutionPlan().GetDetails());
     AssertEquals(2000000, v.Count);
     odb.Close();
 }
Esempio n. 13
0
 private void Merge(NeoDatis.Tool.Wrappers.OdbComparable key, NeoDatis.Odb.Values
                    values)
 {
     while (values.HasNext())
     {
         if (queryHasOrderBy)
         {
             result.AddWithKey(key, values.NextValues());
         }
         else
         {
             result.Add(values.NextValues());
         }
     }
 }
Esempio n. 14
0
 public virtual void Test1()
 {
     DeleteBase("valuesA");
     NeoDatis.Odb.ODB odb = Open("valuesA");
     odb.Store(new NeoDatis.Odb.Test.VO.Login.Function("f1"));
     odb.Close();
     odb = Open("valuesA");
     NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                    (typeof(NeoDatis.Odb.Test.VO.Login.Function)).Field("name"));
     Println(values);
     NeoDatis.Odb.ObjectValues ov = values.NextValues();
     odb.Close();
     AssertEquals("f1", ov.GetByAlias("name"));
     AssertEquals("f1", ov.GetByIndex(0));
 }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.Exception"></exception>
        public virtual void Test1()
        {
            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 < 10; i++)
            {
                handler.AddParameter(new NeoDatis.Odb.Test.Query.Values.Parameter("test " + i, "value "
                                                                                  + i));
            }
            NeoDatis.Odb.OID oid = odb.Store(handler);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                           (typeof(NeoDatis.Odb.Test.Query.Values.Handler), oid).Field("parameters").Sublist
                                                           ("parameters", "sub1", 1, 5, true).Sublist("parameters", "sub2", 1, 10).Size("parameters"
                                                                                                                                        , "size"));
            Println(values);
            NeoDatis.Odb.ObjectValues ov       = values.NextValues();
            System.Collections.IList  fulllist = (System.Collections.IList)ov.GetByAlias("parameters"
                                                                                         );
            AssertEquals(10, fulllist.Count);
            long size = (long)ov.GetByAlias("size");

            AssertEquals(10, size);
            NeoDatis.Odb.Test.Query.Values.Parameter p = (NeoDatis.Odb.Test.Query.Values.Parameter
                                                          )fulllist[0];
            AssertEquals("value 0", p.GetValue());
            NeoDatis.Odb.Test.Query.Values.Parameter p2 = (NeoDatis.Odb.Test.Query.Values.Parameter
                                                           )fulllist[9];
            AssertEquals("value 9", p2.GetValue());
            System.Collections.IList sublist = (System.Collections.IList)ov.GetByAlias("sub1"
                                                                                       );
            AssertEquals(5, sublist.Count);
            p = (NeoDatis.Odb.Test.Query.Values.Parameter)sublist[0];
            AssertEquals("value 1", p.GetValue());
            p2 = (NeoDatis.Odb.Test.Query.Values.Parameter)sublist[4];
            AssertEquals("value 5", p2.GetValue());
            System.Collections.IList sublist2 = (System.Collections.IList)ov.GetByAlias("sub2"
                                                                                        );
            AssertEquals(9, sublist2.Count);
            odb.Close();
        }
Esempio n. 17
0
 // This method os not used in Values Query API
 public virtual void ObjectMatch(NeoDatis.Odb.OID oid, object @object, NeoDatis.Tool.Wrappers.OdbComparable
                                 orderByKey)
 {
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap values = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                                                       )@object;
     NeoDatis.Tool.Wrappers.OdbComparable groupByKey = NeoDatis.Odb.Core.Query.Execution.IndexTool
                                                       .BuildIndexKey("GroupBy", values, groupByFieldList);
     NeoDatis.Odb.Impl.Core.Query.Values.ValuesQueryResultAction result = groupByResult
                                                                          [groupByKey];
     if (result == null)
     {
         result = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesQueryResultAction(query, null
                                                                                  , instanceBuilder);
         result.Start();
         groupByResult.Add(groupByKey, result);
     }
     result.ObjectMatch(oid, @object, orderByKey);
 }
Esempio n. 18
0
 public virtual void Test17()
 {
     DeleteBase("valuesA2");
     NeoDatis.Odb.ODB odb = Open("valuesA2");
     odb.Store(new NeoDatis.Odb.Test.VO.Login.User("user1", "email1", new NeoDatis.Odb.Test.VO.Login.Profile
                                                       ("profile name", new NeoDatis.Odb.Test.VO.Login.Function("f111"))));
     odb.Close();
     odb = Open("valuesA2");
     NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                    (typeof(NeoDatis.Odb.Test.VO.Login.User)).Field("name").Field("profile"));
     Println(values);
     NeoDatis.Odb.ObjectValues ov = values.NextValues();
     odb.Close();
     AssertEquals("user1", ov.GetByAlias("name"));
     AssertEquals("user1", ov.GetByIndex(0));
     NeoDatis.Odb.Test.VO.Login.Profile p2 = (NeoDatis.Odb.Test.VO.Login.Profile)ov.GetByAlias
                                                 ("profile");
     AssertEquals("profile name", p2.GetName());
 }
Esempio n. 19
0
 public virtual void Test5()
 {
     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.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                  (typeof(NeoDatis.Odb.Test.VO.Human.Man)).Field("specie");
     q.SetPolymorphic(true);
     NeoDatis.Odb.Values os = odb.GetValues(q);
     Println(os);
     odb.Close();
     AssertEquals(1, os.Count);
     DeleteBase("multi");
 }
Esempio n. 20
0
        /// <summary>Using Object representation instead of real object</summary>
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.Exception"></exception>
        public virtual void Test5()
        {
            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.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                         (typeof(NeoDatis.Odb.Test.Query.Values.Handler)).Sublist("parameters", "sub", 0,
                                                                                                                  2, true);
            NeoDatis.Odb.Values values = odb.GetValues(q);
            long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            Println("time to load sublist of 5 itens for " + sublistSize + " : " + (end - start
                                                                                    ));
            Println(values);
            NeoDatis.Odb.ObjectValues ov      = values.NextValues();
            System.Collections.IList  sublist = (System.Collections.IList)ov.GetByAlias("sub");
            AssertEquals(2, sublist.Count);
            NeoDatis.Odb.Test.Query.Values.Parameter parameter = (NeoDatis.Odb.Test.Query.Values.Parameter
                                                                  )sublist[1];
            AssertEquals("value 1", parameter.GetValue());
            NeoDatis.Odb.OID oid = odb.GetObjectId(parameter);
            Println(oid);
            odb.Close();
        }
Esempio n. 21
0
 public virtual void Start()
 {
     if (query != null && query.HasOrderBy())
     {
         result = new NeoDatis.Odb.Impl.Core.Query.List.Values.InMemoryBTreeCollectionForValues
                      ((int)nbObjects, query.GetOrderByType());
     }
     else
     {
         result = new NeoDatis.Odb.Impl.Core.Query.List.Values.SimpleListForValues((int)nbObjects
                                                                                   );
     }
     NeoDatis.Odb.Core.Query.Execution.IQueryFieldAction qfa = null;
     for (int i = 0; i < returnArraySize; i++)
     {
         qfa = queryFieldActions[i];
         qfa.Start();
     }
 }
Esempio n. 22
0
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.Exception"></exception>
        public virtual void Test2()
        {
            DeleteBase("valuesSubList2");
            NeoDatis.Odb.ODB odb = Open("valuesSubList2");
            NeoDatis.Odb.Test.Query.Values.Handler handler = new NeoDatis.Odb.Test.Query.Values.Handler
                                                                 ();
            for (int i = 0; i < 500; i++)
            {
                handler.AddParameter(new NeoDatis.Odb.Test.Query.Values.Parameter("test " + i, "value "
                                                                                  + i));
            }
            NeoDatis.Odb.OID oid = odb.Store(handler);
            odb.Close();
            odb = Open("valuesSubList2");
            NeoDatis.Odb.Test.Query.Values.Handler h = (NeoDatis.Odb.Test.Query.Values.Handler
                                                        )odb.GetObjectFromId(oid);
            Println("size of list = " + h.GetListOfParameters().Count);
            long start = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                           (typeof(NeoDatis.Odb.Test.Query.Values.Handler)).Sublist("parameters", "sub", 490
                                                                                                                    , 5, true).Size("parameters", "size"));
            long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            Println("time to load sublist of 5 itens from 40000 : " + (end - start));
            Println(values);
            NeoDatis.Odb.ObjectValues ov      = values.NextValues();
            System.Collections.IList  sublist = (System.Collections.IList)ov.GetByAlias("sub");
            AssertEquals(5, sublist.Count);
            long size = (long)ov.GetByAlias("size");

            AssertEquals(500, size);
            NeoDatis.Odb.Test.Query.Values.Parameter p = (NeoDatis.Odb.Test.Query.Values.Parameter
                                                          )sublist[0];
            AssertEquals("value 490", p.GetValue());
            NeoDatis.Odb.Test.Query.Values.Parameter p2 = (NeoDatis.Odb.Test.Query.Values.Parameter
                                                           )sublist[4];
            AssertEquals("value 494", p2.GetValue());
            odb.Close();
        }
Esempio n. 23
0
 public virtual void Test3()
 {
     DeleteBase("values2");
     NeoDatis.Odb.ODB odb = Open("values2");
     NeoDatis.Odb.Test.VO.Login.Profile p1 = new NeoDatis.Odb.Test.VO.Login.Profile("profile1"
                                                                                    , new NeoDatis.Odb.Test.VO.Login.Function("f1"));
     NeoDatis.Odb.Test.VO.Login.Profile p2 = new NeoDatis.Odb.Test.VO.Login.Profile("profile2"
                                                                                    , new NeoDatis.Odb.Test.VO.Login.Function("f2"));
     NeoDatis.Odb.Test.VO.Login.User u1 = new NeoDatis.Odb.Test.VO.Login.User2("user1"
                                                                               , "*****@*****.**", p1, 1);
     NeoDatis.Odb.Test.VO.Login.User u2 = new NeoDatis.Odb.Test.VO.Login.User2("user2"
                                                                               , "*****@*****.**", p1, 2);
     NeoDatis.Odb.Test.VO.Login.User u3 = new NeoDatis.Odb.Test.VO.Login.User2("user3"
                                                                               , "*****@*****.**", p1, 3);
     NeoDatis.Odb.Test.VO.Login.User u4 = new NeoDatis.Odb.Test.VO.Login.User2("user4"
                                                                               , "*****@*****.**", p2, 4);
     NeoDatis.Odb.Test.VO.Login.User u5 = new NeoDatis.Odb.Test.VO.Login.User2("user5"
                                                                               , "*****@*****.**", p2, 5);
     odb.Store(u1);
     odb.Store(u2);
     odb.Store(u3);
     odb.Store(u4);
     odb.Store(u5);
     odb.Close();
     odb = Open("values2");
     NeoDatis.Odb.Core.Query.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                  (typeof(NeoDatis.Odb.Test.VO.Login.User2)).Field("profile.name").Count("count").
                                              Avg("nbLogins", "avg").GroupBy("profile.name");
     q.OrderByAsc("name");
     NeoDatis.Odb.Values values = odb.GetValues(q);
     Println(values);
     NeoDatis.Odb.ObjectValues ov = values.NextValues();
     AssertEquals(2, values.Count);
     AssertEquals("profile1", ov.GetByAlias("profile.name"));
     AssertEquals(new System.Decimal("3"), ov.GetByAlias("count"));
     AssertEquals(new System.Decimal("2.00"), ov.GetByAlias("avg"));
     odb.Close();
     AssertEquals(2, values.Count);
 }
Esempio n. 24
0
        /// <summary>Using Object representation instead of real object</summary>
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.Exception"></exception>
        public virtual void Test3()
        {
            int sublistSize = 10000;

            DeleteBase("valuesSubList3");
            NeoDatis.Odb.ODB odb = Open("valuesSubList3");
            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.IValuesQuery q = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                         (typeof(NeoDatis.Odb.Test.Query.Values.Handler)).Sublist("parameters", "sub", 9990
                                                                                                                  , 5, true);
            q.SetReturnInstance(false);
            NeoDatis.Odb.Values values = odb.GetValues(q);
            long end = NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs();

            Println("time to load sublist of 5 itens from 40000 : " + (end - start));
            Println(values);
            NeoDatis.Odb.ObjectValues ov      = values.NextValues();
            System.Collections.IList  sublist = (System.Collections.IList)ov.GetByAlias("sub");
            AssertEquals(5, sublist.Count);
            NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                             )sublist[0];
            AssertEquals("value 9990", nnoi.GetValueOf("value"));
            NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi2 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                              )sublist[4];
            AssertEquals("value 9994", nnoi2.GetValueOf("value"));
            odb.Close();
        }
Esempio n. 25
0
 /// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1()
 {
     DeleteBase("valuesA1");
     NeoDatis.Odb.ODB odb = Open("valuesA1");
     NeoDatis.Odb.Test.Query.Values.Handler handler = new NeoDatis.Odb.Test.Query.Values.Handler
                                                          ();
     for (int i = 0; i < 10; i++)
     {
         handler.AddParameter(new NeoDatis.Odb.Test.Query.Values.Parameter("test " + i, "value"
                                                                           + i));
     }
     odb.Store(handler);
     odb.Close();
     odb = Open("valuesA1");
     NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                    (typeof(NeoDatis.Odb.Test.Query.Values.Handler)).Field("parameters"));
     Println(values);
     NeoDatis.Odb.ObjectValues ov = values.NextValues();
     System.Collections.IList  l  = (System.Collections.IList)ov.GetByAlias("parameters"
                                                                            );
     AssertEquals(10, l.Count);
     odb.Close();
 }
Esempio n. 26
0
        public virtual void Test5()
        {
            DeleteBase("valuesA2");
            NeoDatis.Odb.ODB odb = Open("valuesA2");
            int size             = isLocal ? 100000 : 1000;

            for (int i = 0; i < size; i++)
            {
                NeoDatis.Odb.Test.VO.Attribute.TestClass tc1 = new NeoDatis.Odb.Test.VO.Attribute.TestClass
                                                                   ();
                tc1.SetInt1(45);
                odb.Store(tc1);
            }
            odb.Close();
            odb = Open("valuesA2");
            NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                           (typeof(NeoDatis.Odb.Test.VO.Attribute.TestClass)).Count("nb objects"));
            Println(values);
            NeoDatis.Odb.ObjectValues ov = values.NextValues();
            odb.Close();
            AssertEquals(size, ov.GetByAlias("nb objects"));
            AssertEquals(1, values.Count);
        }
Esempio n. 27
0
 public virtual void Test4()
 {
     DeleteBase("valuesA2");
     NeoDatis.Odb.ODB odb = Open("valuesA2");
     NeoDatis.Odb.Test.VO.Attribute.TestClass tc1 = new NeoDatis.Odb.Test.VO.Attribute.TestClass
                                                        ();
     tc1.SetInt1(45);
     odb.Store(tc1);
     NeoDatis.Odb.Test.VO.Attribute.TestClass tc2 = new NeoDatis.Odb.Test.VO.Attribute.TestClass
                                                        ();
     tc2.SetInt1(5);
     odb.Store(tc2);
     odb.Close();
     odb = Open("valuesA2");
     NeoDatis.Odb.Values values = odb.GetValues(new NeoDatis.Odb.Impl.Core.Query.Values.ValuesCriteriaQuery
                                                    (typeof(NeoDatis.Odb.Test.VO.Attribute.TestClass)).Sum("int1", "sum of int1").Count
                                                    ("nb objects"));
     Println(values);
     NeoDatis.Odb.ObjectValues ov = values.NextValues();
     odb.Close();
     AssertEquals(50, ov.GetByAlias("sum of int1"));
     AssertEquals(2, ov.GetByAlias("nb objects"));
     AssertEquals(1, values.Count);
 }
Esempio n. 28
0
 // Nothing to do
 public virtual void End()
 {
     if (query != null && query.HasOrderBy())
     {
         result = new NeoDatis.Odb.Impl.Core.Query.List.Values.InMemoryBTreeCollectionForValues
                      ((int)nbObjects, query.GetOrderByType());
     }
     else
     {
         result = new NeoDatis.Odb.Impl.Core.Query.List.Values.SimpleListForValues((int)nbObjects
                                                                                   );
     }
     System.Collections.IEnumerator iterator = groupByResult.Keys.GetEnumerator();
     NeoDatis.Odb.Impl.Core.Query.Values.ValuesQueryResultAction vqra = null;
     NeoDatis.Tool.Wrappers.OdbComparable key = null;
     while (iterator.MoveNext())
     {
         key  = (NeoDatis.Tool.Wrappers.OdbComparable)iterator.Current;
         vqra = (NeoDatis.Odb.Impl.Core.Query.Values.ValuesQueryResultAction)groupByResult
                [key];
         vqra.End();
         Merge(key, vqra.GetValues());
     }
 }