コード例 #1
0
        static void Main(string[] args)
        {
            DBEngine <int, DBElement <int, string> > dbType1 = new DBEngine <int, DBElement <int, string> >();
            DBEngine <string, DBElement <string, List <string> > > dbCollectionType = new DBEngine <string, DBElement <string, List <string> > >();
            DBItemEditor editor = new DBItemEditor();

            "\nDemonstrating Requirement #2 - Primitive Type DB".title();
            DBElement <int, string> elem1 = new DBElement <int, string>();

            elem1.name      = "Jurassic World";
            elem1.descr     = "Story on escape from giant creatures";
            elem1.timeStamp = DateTime.Now;
            elem1.payload   = "A giant creature attacks the park and becomes a killing machine";
            editor.addKeyValyePair <int, String>(dbType1, elem1, DBElementExtensions.generate_int_key());

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

            elem2.name      = "Cast Away";
            elem2.descr     = "Story of surviving a crash landing on a deserted island.";
            elem2.timeStamp = DateTime.Now;
            elem2.children.AddRange(new List <int> {
                4, 5
            });
            elem2.payload = "Directed by Robert Zemeckis and written by Willian Broyles Jr.";
            editor.addKeyValyePair <int, String>(dbType1, elem2, DBElementExtensions.generate_int_key());
            dbType1.showDB();

            int timeInterval = 2000;
            Scheduler <int, DBElement <int, string>, List <string>, string> sch = new Scheduler <int, DBElement <int, string>, List <string>, string>(dbType1, timeInterval);
        }
コード例 #2
0
        //----< Demonstrating req 3 - addition/deletion of key/value database for primitive type db>-------------------
        public void TestR3(DBEngine <int, DBElement <int, string> > dbType1, DBEngine <string, DBElement <string, List <string> > > dbType2, DBItemEditor editor)
        {
            "\nDemonstrating Requirement #3 Primitive Type".title();
            int key1 = DBElementExtensions.generate_int_key();

            WriteLine("\n\n Addition of Key/value pair");
            WriteLine(" Before Adding Key : " + key1);
            dbType1.showDB();

            WriteLine("\n\n After adding key :" + key1);
            DBElement <int, string> elem1 = new DBElement <int, string>();

            elem1.name      = "Titanic";
            elem1.descr     = "A seventeen-year-old aristocrat falls in love with a kind";
            elem1.timeStamp = DateTime.Now;
            elem1.children.AddRange(new List <int> {
                114, 116
            });
            elem1.payload = "Stars: Leonardo DiCaprio, Kate Winslet, Billy Zane";
            editor.addKeyValyePair <int, String>(dbType1, elem1, key1);
            dbType1.showDB();

            IEnumerable <int> keys1 = dbType1.Keys();
            int first = keys1.First();

            WriteLine("\n\n Removal of Key/value pair");
            WriteLine(" Before removing key :" + first);
            dbType1.showDB();

            WriteLine("\n\n After removing key :" + first);
            editor.removeKey <int, string>(dbType1, first);
            dbType1.showDB();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            DBEngine <int, DBElement <int, string> > dbType1 = new DBEngine <int, DBElement <int, string> >();
            DBEngine <string, DBElement <string, List <string> > > dbType2 = new DBEngine <string, DBElement <string, List <string> > >();
            DBItemEditor editor = new DBItemEditor();

            //Demonstrating primitive type
            DBElement <int, string> elem1 = new DBElement <int, string>();

            elem1.name      = "Jurassic World";
            elem1.descr     = "Story on escape from giant creatures";
            elem1.timeStamp = DateTime.Now;
            elem1.payload   = "A giant creature attacks the park and becomes a killing machine";
            editor.addKeyValyePair <int, String>(dbType1, elem1, DBElementExtensions.generate_int_key());

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

            elem2.name      = "Cast Away";
            elem2.descr     = "Story of surviving a crash landing on a deserted island.";
            elem2.timeStamp = DateTime.Now;
            elem2.children.AddRange(new List <int> {
                4, 5
            });
            elem2.payload = "Directed by Robert Zemeckis and written by Willian Broyles Jr.";
            editor.addKeyValyePair <int, String>(dbType1, elem2, DBElementExtensions.generate_int_key());
            dbType1.showDB();

            QueryEngine <int, string> queryEnginePrimitive = new QueryEngine <int, string>(dbType1);

            string inputString = "11";

            Write("\n\n \n Input Search String :" + inputString);
            List <int> resultList = queryEnginePrimitive.searchKeyPattern(inputString);

            foreach (int key in resultList)
            {
                Write("\n  found \"{0}\" in key \"{1}\"", inputString, key);
            }

            string inputString2 = "Movie";

            Write("\n\n  Input Search String :" + inputString);
            List <int> resultList2 = queryEnginePrimitive.searchMetadataPattern(inputString2);

            foreach (int key in resultList2)
            {
                Write("\n  found \"{0}\" in \"{1}\"", inputString, key);
            }

            DateTime startDate = new DateTime(2014, DateTime.Today.Month, DateTime.Today.Day, 00, 00, 01);
            DateTime endDate   = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59);

            List <int> resultList3 = queryEnginePrimitive.searchTimeStamp(startDate);

            foreach (int key in resultList3)
            {
                Write("\n  found key within \"{0}\" within range \"{1}\" {2}", key, startDate, endDate);
            }
        }
コード例 #4
0
        //----< Demonstrating req 2 - creating generic key/value in-memory database>-------------------
        public void TestR2(DBEngine <int, DBElement <int, string> > dbType1, DBEngine <string, DBElement <string, List <string> > > dbType2, DBItemEditor editor)
        {
            //Demonstrating primitive type
            "\nDemonstrating Requirement #2 - Primitive Type DB".title();
            DBElement <int, string> elem1 = new DBElement <int, string>();

            elem1.name      = "Jurassic World";
            elem1.descr     = "Story on escape from giant creatures";
            elem1.timeStamp = DateTime.Now;
            elem1.payload   = "A giant creature attacks the park and becomes a killing machine";
            editor.addKeyValyePair <int, String>(dbType1, elem1, DBElementExtensions.generate_int_key());

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

            elem2.name      = "Cast Away";
            elem2.descr     = "Story of surviving a crash landing on a deserted island.";
            elem2.timeStamp = DateTime.Now;
            elem2.children.AddRange(new List <int> {
                113, 116
            });
            elem2.payload = "Directed by Robert Zemeckis and written by Willian Broyles Jr.";
            editor.addKeyValyePair <int, String>(dbType1, elem2, DBElementExtensions.generate_int_key());
            dbType1.showDB();

            //Demostrating IEnumberable Type
            "\nDemonstrating Requirement #2 - Collection Type DB".title();
            DBElement <string, List <string> > newerelem1 = new DBElement <string, List <string> >();

            newerelem1.name    = "Movie Name - The Good the Bad and the Ugly";
            newerelem1.descr   = "A bounty hunting scam joins two men in an uneasy alliance ";
            newerelem1.payload = new List <string> {
                "Clint Eastwood", " Eli Wallach", "Lee Van Cleef"
            };
            String key = "The Good, the Bad and the Ugly";

            editor.addKeyValyePair <string, List <String>, string>(dbType2, newerelem1, key);

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

            newerelem2.name  = "Movie Name - Django Unchained";
            newerelem2.descr = "With the help of a German hunter, a freed slave sets to rescue";
            newerelem2.children.AddRange(new[] { key, "Life Is Beautiful" });
            newerelem2.payload = new List <string> {
                "Jamie Foxx", "Christoph Waltz", "Leonardo DiCaprio"
            };
            newerelem2.payload.Add("Quentin Tarantino");
            String key1 = "Django Unchained";

            editor.addKeyValyePair <string, List <String>, string>(dbType2, newerelem2, key1);
            dbType2.showEnumerableDB();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            "Demonstrating Persist Engine".title('=');
            DBEngine <int, DBElement <int, string> > dbType1 = new DBEngine <int, DBElement <int, string> >();
            DBEngine <string, DBElement <string, List <string> > > dbType2 = new DBEngine <string, DBElement <string, List <string> > >();

            //Demonstrating primitive type
            DBElement <int, string> elem1 = new DBElement <int, string>();

            elem1.name      = "Jurassic World";
            elem1.descr     = "Story on escape from giant creatures";
            elem1.timeStamp = DateTime.Now;
            elem1.payload   = "A giant creature attacks the park and becomes a killing machine";
            dbType1.insert(DBElementExtensions.generate_int_key(), elem1);

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

            elem2.name      = "Cast Away";
            elem2.descr     = "Story of surviving a crash landing on a deserted island.";
            elem2.timeStamp = DateTime.Now;
            elem2.children.AddRange(new List <int> {
                4, 5
            });
            elem2.payload = "Directed by Robert Zemeckis and written by Willian Broyles Jr.";
            dbType1.insert(DBElementExtensions.generate_int_key(), elem2);
            dbType1.showDB();

            //Demostrating IEnumberable Type
            DBElement <string, List <string> > newerelem1 = new DBElement <string, List <string> >();

            newerelem1.name    = "Movie Name - The Good the Bad and the Ugly";
            newerelem1.descr   = "A bounty hunting scam joins two men in an uneasy alliance ";
            newerelem1.payload = new List <string> {
                "Clint Eastwood", " Eli Wallach", "Lee Van Cleef"
            };
            String key = "The Good, the Bad and the Ugly";

            dbType2.insert(key, newerelem1);

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

            newerelem2.name  = "Movie Name - Django Unchained";
            newerelem2.descr = "With the help of a German hunter, a freed slave sets to rescue";
            newerelem2.children.AddRange(new[] { key, "Life Is Beautiful" });
            newerelem2.payload = new List <string> {
                "Jamie Foxx", "Christoph Waltz", "Leonardo DiCaprio"
            };
            newerelem2.payload.Add("Quentin Tarantino");
            String key1 = "Django Unchained";

            dbType2.insert(key1, newerelem2);
            dbType2.showEnumerableDB();

            string xmlFile1 = "nosqdldb_primitive.xml";

            dbType1.persist_db <int, DBElement <int, string>, string>(xmlFile1);
            WriteLine("\nSuccesfully persisted dbengine contents to xml file :" + xmlFile1);

            string xmlFile2 = "nosqdldb.xml";

            dbType2.persist_db <string, DBElement <string, List <string> >, List <string>, string>(xmlFile2);
            WriteLine("\nSuccesfully persisted dbengine contents to xml file :  " + xmlFile2);

            string xmlFile3 = "read_nosqldb_primitive.xml";

            WriteLine("\n\n Before Augumenting DB from xml file : " + xmlFile3);
            dbType1.showDB();
            dbType1.augument_db <int, DBElement <int, string>, string>(xmlFile3);
            WriteLine("\n\n After Augumenting DB from xml file : " + xmlFile3);
            dbType1.showDB();

            string xmlFile4 = "read_nosqdldb.xml";

            WriteLine("\n\n Before Augumenting DB from xml file : " + xmlFile4);
            dbType2.showEnumerableDB();
            dbType2.augument_db <string, DBElement <string, List <string> >, List <string>, string>(xmlFile4);
            WriteLine("\n\n After Augumenting DB from xml file : " + xmlFile4);
            dbType2.showEnumerableDB();

            DBEngine <int, DBElement <int, string> > dbType1New = new DBEngine <int, DBElement <int, string> >();
            DBEngine <string, DBElement <string, List <string> > > dbType2New = new DBEngine <string, DBElement <string, List <string> > >();

            string xmlFile5 = "read_nosqldb_primitive.xml";

            WriteLine("\n\n Before Restoring DB from xml file : " + xmlFile5);
            dbType1New.showDB();
            dbType1New.augument_db <int, DBElement <int, string>, string>(xmlFile5);
            WriteLine("\n\n After Restoring DB from xml file : " + xmlFile5);
            dbType1New.showDB();

            string xmlFile6 = "read_nosqdldb.xml";

            WriteLine("\n\n Before Restoring DB from xml file : " + xmlFile6);
            dbType2New.showEnumerableDB();
            dbType2New.augument_db <string, DBElement <string, List <string> >, List <string>, string>(xmlFile6);
            WriteLine("\n\n After Restoring DB from xml file : " + xmlFile6);
            dbType2New.showEnumerableDB();
        }
コード例 #6
0
        static void Main(string[] args)
        {
            DBEngine <int, DBElement <int, string> > dbType1 = new DBEngine <int, DBElement <int, string> >();
            DBEngine <string, DBElement <string, List <string> > > dbType2 = new DBEngine <string, DBElement <string, List <string> > >();
            DBItemEditor editor = new DBItemEditor();

            //Demonstrating primitive type
            "\nDemonstrating Requirement #2 - Primitive Type DB".title();
            DBElement <int, string> elem1 = new DBElement <int, string>();

            elem1.name      = "Jurassic World";
            elem1.descr     = "Story on escape from giant creatures";
            elem1.timeStamp = DateTime.Now;
            elem1.payload   = "A giant creature attacks the park and becomes a killing machine";
            editor.addKeyValyePair <int, String>(dbType1, elem1, DBElementExtensions.generate_int_key());

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

            elem2.name      = "Cast Away";
            elem2.descr     = "Story of surviving a crash landing on a deserted island.";
            elem2.timeStamp = DateTime.Now;
            elem2.children.AddRange(new List <int> {
                4, 5
            });
            elem2.payload = "Directed by Robert Zemeckis and written by Willian Broyles Jr.";
            editor.addKeyValyePair <int, String>(dbType1, elem2, DBElementExtensions.generate_int_key());
            dbType1.showDB();

            Console.WriteLine("\n\n Before updating metadata");
            IEnumerable <int> keys1 = dbType1.Keys();
            int first = keys1.First();

            dbType1.showDB();
            Console.WriteLine("\n\n After updating metadata");
            editor.updateMetadataInfo <int, String>(dbType1, first, "Reborn -Cast Away", "The guy who survived in deserted insland");

            dbType1.showDB();

            IEnumerable <int> keys = dbType1.Keys();
            int firstDB1Key        = keys.ElementAt(0);
            int secondDB1Key       = keys.ElementAt(1);

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

            elem22.name      = "Titanic Reborn";
            elem22.descr     = "A new movie directed in 2015 with the same plot line";
            elem22.timeStamp = DateTime.Now;
            elem22.children.AddRange(new List <int> {
                1
            });
            elem22.payload = "The movie will feature same actors but director changes";
            editor.updatePayloadInfo <int, String>(dbType1, elem22, secondDB1Key);

            Console.WriteLine("\n\n Before adding child Instance " + secondDB1Key + " from key " + firstDB1Key);
            dbType1.showDB();
            editor.addChildren <int, string>(dbType1, firstDB1Key, secondDB1Key);
            Console.WriteLine("\n\n After adding child Instance : " + secondDB1Key + " from key " + firstDB1Key);
            dbType1.showDB();

            Console.WriteLine("\n\n Before removing child Instance key " + 114 + " from key " + firstDB1Key);
            dbType1.showDB();
            editor.removeChildren <int, string>(dbType1, firstDB1Key, 114);
            Console.WriteLine("\n\n After removing child Instance key " + 114 + " from key " + firstDB1Key);
            dbType1.showDB();
        }