Esempio n. 1
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. 2
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();
        }