예제 #1
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();
        }
예제 #2
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();
        }
예제 #3
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();
        }
예제 #4
0
        /// <summary>Check if objects of list are known by ODB</summary>
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.Exception"></exception>
        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();
        }