Esempio n. 1
0
        void TestR7()
        {
            "\n1) Fetch Value for key 3".title();
            var val = db.getValueOfKey(3);

            val.showElement();
            WriteLine();

            qEngine = new QueryEngine <int, DBElement <int, string> >(db);
            "\n2) Fetch the children of key 1".title();
            var children = qEngine.getChildrenOfKey(1);

            displayChildren(children);

            "\n3) Fetch the keys which starts with r in the below database with key/value pairs".title();             //Taking new database with string keys
            DBElement <string, List <string> > elem = new DBElement <string, List <string> >();

            elem.name      = "Christ college";
            elem.descr     = "College where the person studied";
            elem.timeStamp = DateTime.Now;
            elem.children.AddRange(new List <string> {
                "rakesh"
            });
            elem.payload = new List <string> {
                "One", "Two", "Three", "Four"
            };
            dbString.insert("saahith", elem);

            DBElement <string, List <string> > elem1 = new DBElement <string, List <string> >();

            elem1.name      = "PESIT college";
            elem1.descr     = "College where the person pursued undergraduation";
            elem1.timeStamp = DateTime.Now.AddDays(-2);
            elem1.children.AddRange(new List <string> {
                "saahith"
            });
            elem1.payload = new List <string> {
                "Five", "Six", "Seven", "Eight"
            };
            dbString.insert("rakesh", elem1);
            dbString.showEnumerableDB();
            WriteLine();

            qEngine2 = new QueryEngine <string, DBElement <string, List <string> > >(dbString);
            string pattern1 = @"(^r)";
            var    spKeys   = qEngine2.getListStringKeyPattern(pattern1);

            displayStringKeys(spKeys);

            "\n4) Fetch keys with metadata pattern 'Name'".title();
            string pattern = "Name";
            var    mdKeys  = qEngine.getListMetaDataPattern(pattern);

            displayKeys(mdKeys);

            "\n5) Fetch keys which are created between two dates 29th sept 2015 and 15th oct 2015".title();
            DateTime time1  = new DateTime(2015, 9, 29);
            DateTime time2  = new DateTime(2015, 10, 15);
            var      tpKeys = qEngine.getListTimePattern(time1, time2);

            displayKeys(tpKeys);
        }
        static void Main(string[] args)
        {
            "Testing ItemEditor Package".title('=');
            Console.WriteLine();

            DBEngine <int, DBElement <int, string> > db = new DBEngine <int, DBElement <int, string> >();

            DBElement <int, string> elem1 = new DBElement <int, string>();

            elem1.name      = "India";
            elem1.descr     = "Country";
            elem1.timeStamp = DateTime.Now;
            elem1.children.AddRange(new List <int> {
                2, 3
            });
            elem1.payload = "Famous cricket player";
            db.insert(1, elem1);


            DBElement <int, string> elem2 = new DBElement <int, string>();                            //Add new key/value pairs to the database

            elem2.name      = "Roger federer";
            elem2.descr     = "Tennis player";
            elem2.timeStamp = DateTime.Now.AddDays(-15);
            elem2.children.AddRange(new List <int> {
                3
            });
            elem2.payload = "Famous tennis player";
            db.insert(2, elem2);

            DBElement <int, string> elem3 = new DBElement <int, string>();

            elem3.name      = "Usain Bolt";
            elem3.descr     = "Athelte";
            elem3.timeStamp = DateTime.Now;
            elem3.children.AddRange(new List <int> {
                1
            });
            elem3.payload = "Fastest in the world";
            db.insert(3, elem3);
            Console.WriteLine();
            db.showDB();

            "\n1) Fetch Value for key 3".title();
            var val = db.getValueOfKey(3);

            val.showElement();
            Console.WriteLine();

            QueryEngine <int, DBElement <int, string> > qEngine = new QueryEngine <int, DBElement <int, string> >(db);

            "\n2) Fetch the children of key 1".title();
            var children = qEngine.getChildrenOfKey(1);

            displayChildren(children);

            DBEngine <string, DBElement <string, List <string> > > db2 = new DBEngine <string, DBElement <string, List <string> > >();

            "\n 3) Fetch the keys which starts with r in the below database with key/value pairs".title();             //Taking new database with string keys
            DBElement <string, List <string> > elem4 = new DBElement <string, List <string> >();

            elem4.name      = "Christ college";
            elem4.descr     = "College where the person studied";
            elem4.timeStamp = DateTime.Now;
            elem4.children.AddRange(new List <string> {
                "rakesh"
            });
            elem4.payload = new List <string> {
                "One", "Two", "Three", "Four"
            };
            db2.insert("saahith", elem4);

            DBElement <string, List <string> > elem5 = new DBElement <string, List <string> >();

            elem5.name      = "PESIT college";
            elem5.descr     = "College where the person pursued undergraduation";
            elem5.timeStamp = DateTime.Now.AddDays(-2);
            elem5.children.AddRange(new List <string> {
                "saahith"
            });
            elem5.payload = new List <string> {
                "Five", "Six", "Seven", "Eight"
            };
            db2.insert("rakesh", elem5);
            db2.showEnumerableDB();
            WriteLine();

            QueryEngine <string, DBElement <string, List <string> > > qEngine2 = new QueryEngine <string, DBElement <string, List <string> > >(db2);
            string pattern1 = @"(^r)";
            var    spKeys   = qEngine2.getListStringKeyPattern(pattern1);

            displayStringKeys(spKeys);

            "\n4) Fetch keys with metadata pattern 'Country'".title();
            string pattern = "Country";
            var    mdKeys  = qEngine.getListMetaDataPattern(pattern);

            displayKeys(mdKeys);

            "\n5) Fetch keys which are created between two dates 29th sept 2015 and 15th oct 2015".title();
            DateTime time1  = new DateTime(2015, 9, 29);
            DateTime time2  = new DateTime(2015, 10, 15);
            var      tpKeys = qEngine.getListTimePattern(time1, time2);

            displayKeys(tpKeys);
        }