void TestR7() { "Demonstrating Requirement #7".title(); "The Value of a specified key".title('-'); WriteLine(); WriteLine(" Query : value of key = 14"); QueryProcessEngine <int, ListOfStrings> queryEngine = new QueryProcessEngine <int, ListOfStrings>(db1); DBElement <int, ListOfStrings> elem1; queryEngine.processValueQuery(14, out elem1); elem1.showElement(); "The children of a specified key".title('-'); WriteLine(" Query : children of key = 1"); List <int> childrens; queryEngine.processChildrenQuery(1, out childrens); WriteLine(" Children of key = 1 "); foreach (var item in childrens) { WriteLine(" --> " + item); } WriteLine(); "The set of all keys matching a specified pattern which defaults to all keys.".title('-'); WriteLine(" Query : Search keys which contains \"1\" in their keys value."); 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('-'); WriteLine(" Query : Search keys/values which contains \"Scheduler\" text in their metadata value."); 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 = new DBFactory <int, DBElement <int, ListOfStrings> >(results); dbFactory.showDBFactory(); }
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(); }