コード例 #1
0
 public static void showEnumerableDB(this DBFactory <string, DBElement <string, List <string> > > db)
 {
     db.show <string, DBElement <string, List <string> >, List <string>, string>();
 }
        static void Main(string[] args)
        {
            "Testing QueryProcessing Package".title('=');
            WriteLine();

            DBEngine <int, DBElement <int, ListOfStrings> > db1 = new DBEngine <int, DBElement <int, ListOfStrings> >();
            DBElement <int, ListOfStrings> elem1 = new DBElement <int, ListOfStrings>();

            elem1.name      = "1st Key/Value = Int/ListOfStrings";
            elem1.descr     = "This is first element of Int/ListOfStrings key value pair.";
            elem1.timeStamp = DateTime.Now;
            elem1.children.AddRange(new List <int> {
                100, 101, 102, 103, 104, 105
            });
            elem1.payload = new ListOfStrings();
            elem1.payload.theWrappedData = new List <string> {
                "CSE681", "SMA", "C#.net", "AI"
            };
            db1.insert(1, elem1);

            DBElement <int, ListOfStrings> elem2 = new DBElement <int, ListOfStrings>();

            elem2.name      = "element int-ListOfString 2";
            elem2.descr     = "test element int-ListOfString 2";
            elem2.timeStamp = DateTime.Now;
            elem2.children.AddRange(new List <int> {
                10, 22, 23, 24, 25, 26
            });
            elem2.payload = new ListOfStrings();
            elem2.payload.theWrappedData = new List <string> {
                "CSE6812", "SMA2", "C#.net2", "AI2"
            };
            db1.insert(2, elem2);

            WriteLine("  Query : value of key = 2");
            QueryProcessEngine <int, ListOfStrings> queryEngine = new QueryProcessEngine <int, ListOfStrings>(db1);
            DBElement <int, ListOfStrings>          result;

            queryEngine.processValueQuery(14, out result);
            result.showElement();

            WriteLine("  Query : Children of key = 1");
            List <int> childrens;

            queryEngine.processChildrenQuery(1, out childrens);
            foreach (var item in childrens)
            {
                WriteLine(item);
            }
            WriteLine();

            "The set of all keys matching a specified pattern which defaults to all keys.".title('-');
            Dictionary <int, DBElement <int, ListOfStrings> > results;

            queryEngine.processPatternMatchInKeysQuery(queryEngine.defineQueryKeyPatternSearch("1"), out results);
            DBFactory <int, DBElement <int, ListOfStrings> > dbFactory = new DBFactory <int, DBElement <int, ListOfStrings> >(results);

            dbFactory.showDBFactory();

            WriteLine();
            "All keys that contain a specified string in their metadata section.".title('-');
            results.Clear();
            queryEngine.processPatternMatchInMetaDataQuery(queryEngine.defineQueryValuePatternSearch("Scheduler"), out results);
            dbFactory = new DBFactory <int, DBElement <int, ListOfStrings> >(results);
            dbFactory.showDBFactory();

            WriteLine();
            "All keys that contain values written within a specified time-date interval".title('-');
            DateTime dt1 = new DateTime(1990, 6, 14, 0, 0, 0);
            DateTime dt2 = new DateTime(1990, 6, 17, 0, 0, 0);

            results.Clear();
            queryEngine.processTimeIntervalQuery(queryEngine.defineTimeStampQuery(dt1, dt2), out results);
            dbFactory.showDBFactory();
        }
コード例 #3
0
ファイル: Display.cs プロジェクト: rakeshh91/Android-Projects
 public static void showDB(this DBFactory <int, DBElement <int, string> > db)
 {
     db.show <int, DBElement <int, string>, string>();
 }
コード例 #4
0
        static void Main(string[] args)
        {
            "Testing DBFactory Package".title('=');
            WriteLine();

            "\nCreation of immutable database".title();
            WriteLine();

            "\nOriginal database".title();
            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>();

            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);

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

            elem4.name      = "Saina Nehwal";
            elem4.descr     = "Badminton Player";
            elem4.timeStamp = DateTime.Now;
            elem4.children.AddRange(new List <int> {
                2
            });
            elem4.payload = "Famous badminton player";
            db.insert(4, elem4);
            db.showDB();
            WriteLine();

            "\n Fetch all the keys which are even from the above database".title();
            try
            {
                QueryEngine <int, DBElement <int, string> > qEngine     = new QueryEngine <int, DBElement <int, string> >(db);
                Dictionary <int, DBElement <int, string> >  dictFactory = new Dictionary <int, DBElement <int, string> >();
                DBFactory <int, DBElement <int, string> >   dbFactory;
                var keys = qEngine.getListKeyPattern();
                if (keys != null)
                {
                    foreach (var key in keys)
                    {
                        var val = db.getValueOfKey(key);
                        dictFactory.Add(key, val);                                                              //add keys and values to the dictionary
                    }
                    dbFactory = new DBFactory <int, DBElement <int, string> >(dictFactory);                     //store the dictionary in the
                    WriteLine("\nThe below key/value pairs with even keys pattern are saved as an immutable database\n");
                    dbFactory.showDB();                                                                         //display the immutable database
                    WriteLine();
                    WriteLine();
                }
                else
                {
                    WriteLine("\nNo keys are obtained from a query for creation of immutable database\n");
                }
                WriteLine();
                WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("\n" + e.Message + "\n");
            }
        }