Esempio n. 1
0
        public static void Test3(DniproDB db)
        {
            db.AddDoc("{'arr':['1','2','3']}");
            db.AddDoc("{'arr':['3','4','2']}");
            db.AddDoc("{'arr':['2','3','4']}");
            db.AddDoc("{'arr':['3','4','5']}");

            db.GetWhere("{'arr':[In,'2','3']}").Print("{'arr':[$, $, $]}");
        }
Esempio n. 2
0
        public static void Test2(DniproDB db)
        {
            db.AddDoc("{'login':'******'}");
            db.AddDoc("{'login':'******'}");
            db.AddDoc("{'login':'******'}");
            db.AddDoc("{'login':'******'}");

            db.GetWhere("{'login':@'mi*'}").Print("{'login':$}");
        }
Esempio n. 3
0
        public static void Test1(DniproDB db)
        {
            Stopwatch s = new Stopwatch();

            s.Start();

            ulong count = 0;

            for (int i = 0; i < 1000; i++)
            {
                count += db.GetWhere("{'Name':'Bill'}").Count();
            }

            s.Stop();

            Console.WriteLine("Test1: " + s.ElapsedMilliseconds.ToString() + "-" + count.ToString());
        }
Esempio n. 4
0
        public static void Test0(DniproDB db)
        {
            List<string> docs = new List<string>();
            for (int i = 0; i < 100000; i++)
            {
                docs.Add("{'id':" + i.ToString() + ",'FirstName':'John" + i.ToString() + "','LastName':'Smith" + i.ToString() + "','arr':[1,2,3,4,5]}");
            }

            Stopwatch s = new Stopwatch();
            s.Start();

            db.AddDocs(docs);

            s.Stop();

            Console.WriteLine("Test0: " + s.ElapsedMilliseconds.ToString());
        }
Esempio n. 5
0
        public static void Test4(DniproDB db)
        {
            db.AddDoc("{'arr':'1'}");
            db.AddDoc("{'arr':'3'}");
            db.AddDoc("{'arr':'2'}");
            db.AddDoc("{'arr':'3'}");

            //string json = db.GetPartDoc("{'Array':[$,$]}", docID);

            db.GetWhere("{'arr':@'1-2'}").Delete("{'arr':$]}");
        }
Esempio n. 6
0
        public static void Test14(DniproDB db)
        {
            Address address = new Address() { Country = "United Kingdom", City = "London" };

            User user = new User()
            {
                FirstName = "John",
                LastName = "Smith",
                Address = address
            };



            //db.DelPartDoc("{'FirstName':$,'LastName':$}", docID);

            //db.DelPartDoc(user, docID);

            db.AddDocs(new object[] { new {Color = "Red" },
                                      new {Color = "Green"},
                                      new {Color = "Blue" }});

            db.AddDoc("{'FirstName':'John', 'LastName':'Smith', 'Status':'Offline'}");

            //save doc
            uint docId = db.AddDoc(user);

            //load doc
            User u2 = db.GetPartDoc<User>(docId);

            //sometime later ....
            //status was changed in the db
            db.UpdPartDoc("{'Status':'Online'}", docId);

            int[] docIDs = db.GetDocsByAttr("{'FirstName':'John'}");

            user = db.GetPartDoc<User>(user, Load.Create(user.Address, LoadEnum.LoadOnlyTopLevel), docId);


            //sometime later ....
            //update only status in the document
            //do not recreate object, do not reload FirstName and LastName !
            db.GetPartDoc<User>(u2, "{'Status':$}", docId);

        }
Esempio n. 7
0
        public static void Test13(DniproDB db)
        {
            PartDoc[] docs = new PartDoc[100000];

            for (int i = 0; i < 100000; i++)
            {
                docs[i].Json = "{'UserId':" + i.ToString() + ",'FirstName':'Заец','LastName':'Зайцев" + i.ToString() + "-й','Arr':[1,2,3,4,5]}";
            }

            Stopwatch s = new Stopwatch();
            s.Start();

            for (int i = 0; i < 100000; i++)
            {
                db.AddDoc(docs[i]);
            }

            s.Stop();

            Console.WriteLine("Test13: " + s.ElapsedMilliseconds.ToString());
        }
Esempio n. 8
0
        public static void Test11(DniproDB db)
        {
            Person[] docs = new Person[100000];

            for (int i = 0; i < 100000; i++)
            {
                docs[i] = new Person
                {
                    UserId = i,
                    FirstName = "Заец",
                    LastName = "Зайцев" + i.ToString() + "-й",
                    Arr = new List<int>() { 1, 2, 3, 4, 5 }
                };
            }

            Stopwatch s = new Stopwatch();
            s.Start();

            db.AddDocs<Person>(docs);

            s.Stop();

            Console.WriteLine("Test11: " + s.ElapsedMilliseconds.ToString());
        }
Esempio n. 9
0
 public static void Clear(DniproDB db)
 {
     db.Clear();
 }
Esempio n. 10
0
        public static void Test10(DniproDB db)
        {
            SerTest st = new SerTest();
            st.Arr = new List<int>();

            for (int i = 0; i < 100; i++)
            {
                st.Arr.Add(i);
            }

            string str = "";// = Serialization.Serialize(st);

            int code = 0;

            //insert pages with comments;
            Stopwatch s = new Stopwatch();

            s.Start();

            for (int i = 0; i < 100000; i++)
            {
                code += Serialization.DeserializeProxy<SerTest>(new SerTest(), str).GetHashCode();
                //code += Serialization.Deserialize<SerTest>(str).GetHashCode();
            }

            s.Stop();

            Console.WriteLine("Inserts: " + s.ElapsedMilliseconds.ToString());
        }
Esempio n. 11
0
        public static void Test9(DniproDB db)
        {
            List<Comment> level1 = new List<Comment>();
            List<Comment> level2 = new List<Comment>();
            List<Comment> level3 = new List<Comment>();

            //initialize data, 10*10*10 comments in each page
            for (int i = 0; i < 10; i++)
            {
                level3.Add(
                    new Comment()
                    {
                        Text = "Blah" + i.ToString()
                    });
            }

            for (int i = 0; i < 10; i++)
            {
                level2.Add(
                    new Comment()
                    {
                        Text = "Blah" + i.ToString(),
                        Childs = level3
                    });
            }

            for (int i = 0; i < 10; i++)
            {
                level1.Add(
                    new Comment()
                    {
                        Text = "Blah" + i.ToString(),
                        Childs = level2
                    });
            }

            Page[] pages = new Page[2500];

            for (int i = 0; i < 2500; i++)
            {
                pages[i] = new Page();
                pages[i].PageId = i;
                pages[i].Childs = level1;
            }

            //insert pages with comments;
            Stopwatch s = new Stopwatch();

            s.Start();

            for (int i = 0; i < 2500; i++)
            {
                //db.AddDoc<Page>(pages[i]);
            }

            s.Stop();

            Console.WriteLine("Inserts: " + s.ElapsedMilliseconds.ToString());

            //read pages with comments
            s = new Stopwatch();
            s.Start();

            for (int i = 0; i < 1000; i++)
            {
                Page[] page = db.GetWhere("{'PageId':1}").Select<Page>();

                //PartDoc[] page = db.GetWhere("{'PageId':1}").Select("{'Childs':[R,{'Text':$,'Childs':[R,{'Text':$,'Childs':[R,{'Text':$}]}]}]}");

                //do something with page
                //...
            }

            s.Stop();

            Console.WriteLine("Read all: " + s.ElapsedMilliseconds.ToString());
        }
Esempio n. 12
0
        public static void Test8(DniproDB db)
        {
            PlanOption[] objs = new PlanOption[500000];

            for (int i = 0; i < 500000; i++)
            {
                objs[i] = new PlanOption() { Prop = Blaha.bla1, ServicePlanID = i, ServicePlanOption = i, IsDefault = true };
            }

            Stopwatch s = new Stopwatch();
            s.Start();

            db.AddDoc(new { hello = "ok" });

            db.AddDocs<PlanOption>(objs);

            s.Stop();

            Console.WriteLine("Inserts: " + s.ElapsedMilliseconds.ToString());

            s = new Stopwatch();
            s.Start();

            objs = db.GetWhere("{'IsDefault':true}").Select<PlanOption>();

            s.Stop();

            Console.WriteLine("Read all: " + s.ElapsedMilliseconds.ToString());
        }
Esempio n. 13
0
        public static void Test7(DniproDB db)
        {
            TO to1 = new TO
            {
                id = 123,
                FirstName = "John",
                LastName = "Smith",
                Arr = new List<int>() { 1, 2, 3, 4, 5 }
            };

            db.AddDoc<TO>(to1);

            TO to2 = new TO
            {
                id = 123,
                FirstName = "John",
                LastName = "Smith",
                Arr = new List<int>() { 7, 4, 2, 8, 9 }
            };

            db.AddDoc<TO>(to2);

            TO[] tos = db.GetWhere("{'Arr':[In,2,4]}").Select<TO>();

            //tos = tos;
        }
Esempio n. 14
0
        public static void Test6(DniproDB db)
        {
            TO[] docs = new TO[50000];

            for (int i = 0; i < 50000; i++)
            {
                docs[i] = new TO
                {
                    id = i,
                    FirstName = "John" + i.ToString(),
                    LastName = "Smith" + i.ToString(),
                    Arr = new List<int>() { 1, 2, 3, 4, 5 }
                };
            }

            Stopwatch s = new Stopwatch();
            s.Start();

            db.AddDocs<TO>(docs);

            s.Stop();

            Console.WriteLine("Test6: " + s.ElapsedMilliseconds.ToString());
        }
Esempio n. 15
0
        public static void Test5(DniproDB db)
        {
            db.AddDoc("{'firstName':'John','lastName':'Smith', 'Value':'1'}");
            db.AddDoc("{'firstName':'John','lastName':'Dereck', 'Value':'2'}");
            db.AddDoc("{'firstName':'John','lastName':'Connor', 'Value':'3'}");
            db.AddDoc("{'firstName':'John','lastName':'Smith', 'Value':'4'}");

            db.GetWhere("{'firstName':'John','lastName':'Smith'}").Print("{'Value':$]}");
        }