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); } }
//----<Demonstrating queries :keys matching a pattern - collection db >------------------- private void testR7c2(DBEngine <string, DBElement <string, List <string> > > dbType2, QueryEngine <string, List <string> > queryEngine) { "\nDemonstrating Requirement #7C - The set of all keys matching a specified pattern - Collection DB".title(); string inputString = "Django"; Write("\n\n Input Search String :" + inputString); List <String> resultList = queryEngine.searchKeyPattern(inputString); foreach (String key in resultList) { Write("\n found \"{0}\" in key \"{1}\"", inputString, key); } }
//----<Demonstrating queries :keys matching a pattern - primitive >------------------- public void testR7c(DBEngine <int, DBElement <int, string> > dbType1, DBEngine <string, DBElement <string, List <string> > > dbType2) { "\nDemonstrating Requirement #7C - The set of all keys matching a specified pattern - Primitive DB".title(); QueryEngine <int, string> queryEngine = new QueryEngine <int, string>(dbType1); QueryEngine <string, List <string> > queryEngineType2 = new QueryEngine <string, List <string> >(dbType2); string inputString = "11"; Write("\n\n Input Search String :" + inputString); List <int> resultList = queryEngine.searchKeyPattern(inputString); foreach (int key in resultList) { Write("\n found \"{0}\" in key \"{1}\"", inputString, key); } testR7c2(dbType2, queryEngineType2); testR7d(dbType2, queryEngineType2); testR7d_primitive(dbType1, queryEngine); testR7e_primitiveType(dbType1, queryEngine); testR7e(dbType2, queryEngineType2); }