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);
            }
        }
示例#2
0
        //----<Demonstrating queries :search within timestamp - primitive db >-------------------
        private void testR7e_primitiveType(DBEngine <int, DBElement <int, string> > dbType1, QueryEngine <int, string> queryEngine)
        {
            "\n Demonstrating Requirement #7E - keys that contain values written within a specified time-date interval ".title();

            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> resultList = queryEngine.searchTimeStamp(startDate);

            foreach (int key in resultList)
            {
                Write("\n  found key within \"{0}\" within range \"{1}\" {2}", key, startDate, endDate);
            }
        }