Ejemplo n.º 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> > > 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);
            }
        }
Ejemplo n.º 2
0
        //----<Demonstrating queries :search in metadata section - collection >-------------------
        private void testR7d(DBEngine <string, DBElement <string, List <string> > > dbType2, QueryEngine <string, List <string> > queryEngine)
        {
            "\n Demonstrating Requirement #7 - All keys that contain a specified string in their metadata section - Collection DB".title();
            string inputString = "Hunter";

            Write("\n\n  Input Search String :" + inputString);
            List <String> resultList = queryEngine.searchMetadataPattern(inputString);

            foreach (String key in resultList)
            {
                Write("\n  found \"{0}\" in key \"{1}\"", inputString, key);
            }
        }
Ejemplo n.º 3
0
        //----<Demonstrating queries :search in metadata section - primitive >-------------------
        private void testR7d_primitive(DBEngine <int, DBElement <int, string> > dbType1, QueryEngine <int, string> queryEngine)
        {
            "\n Demonstrating Requirement #7D - All keys that contain a specified string in their metadata section - Primitive DB".title();
            string inputString = "survived";

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

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