void TestR7() { "\n1) Fetch Value for key 3".title(); var val = db.getValueOfKey(3); val.showElement(); WriteLine(); qEngine = new QueryEngine <int, DBElement <int, string> >(db); "\n2) Fetch the children of key 1".title(); var children = qEngine.getChildrenOfKey(1); displayChildren(children); "\n3) Fetch the keys which starts with r in the below database with key/value pairs".title(); //Taking new database with string keys DBElement <string, List <string> > elem = new DBElement <string, List <string> >(); elem.name = "Christ college"; elem.descr = "College where the person studied"; elem.timeStamp = DateTime.Now; elem.children.AddRange(new List <string> { "rakesh" }); elem.payload = new List <string> { "One", "Two", "Three", "Four" }; dbString.insert("saahith", elem); DBElement <string, List <string> > elem1 = new DBElement <string, List <string> >(); elem1.name = "PESIT college"; elem1.descr = "College where the person pursued undergraduation"; elem1.timeStamp = DateTime.Now.AddDays(-2); elem1.children.AddRange(new List <string> { "saahith" }); elem1.payload = new List <string> { "Five", "Six", "Seven", "Eight" }; dbString.insert("rakesh", elem1); dbString.showEnumerableDB(); WriteLine(); qEngine2 = new QueryEngine <string, DBElement <string, List <string> > >(dbString); string pattern1 = @"(^r)"; var spKeys = qEngine2.getListStringKeyPattern(pattern1); displayStringKeys(spKeys); "\n4) Fetch keys with metadata pattern 'Name'".title(); string pattern = "Name"; var mdKeys = qEngine.getListMetaDataPattern(pattern); displayKeys(mdKeys); "\n5) Fetch keys which are created between two dates 29th sept 2015 and 15th oct 2015".title(); DateTime time1 = new DateTime(2015, 9, 29); DateTime time2 = new DateTime(2015, 10, 15); var tpKeys = qEngine.getListTimePattern(time1, time2); displayKeys(tpKeys); }
static void Main(string[] args) { "Testing DBFactory Package".title('='); WriteLine(); "\nCreation of immutable database".title(); WriteLine(); "\nOriginal database".title(); DBEngine <int, DBElement <int, string> > db = new DBEngine <int, DBElement <int, string> >(); DBElement <int, string> elem1 = new DBElement <int, string>(); elem1.name = "India"; elem1.descr = "Country"; elem1.timeStamp = DateTime.Now; elem1.children.AddRange(new List <int> { 2, 3 }); elem1.payload = "Famous cricket player"; db.insert(1, elem1); DBElement <int, string> elem2 = new DBElement <int, string>(); elem2.name = "Roger federer"; elem2.descr = "Tennis player"; elem2.timeStamp = DateTime.Now.AddDays(-15); elem2.children.AddRange(new List <int> { 3 }); elem2.payload = "Famous tennis player"; db.insert(2, elem2); DBElement <int, string> elem3 = new DBElement <int, string>(); elem3.name = "Usain Bolt"; elem3.descr = "Athelte"; elem3.timeStamp = DateTime.Now; elem3.children.AddRange(new List <int> { 1 }); elem3.payload = "Fastest in the world"; db.insert(3, elem3); DBElement <int, string> elem4 = new DBElement <int, string>(); elem4.name = "Saina Nehwal"; elem4.descr = "Badminton Player"; elem4.timeStamp = DateTime.Now; elem4.children.AddRange(new List <int> { 2 }); elem4.payload = "Famous badminton player"; db.insert(4, elem4); db.showDB(); WriteLine(); "\n Fetch all the keys which are even from the above database".title(); try { QueryEngine <int, DBElement <int, string> > qEngine = new QueryEngine <int, DBElement <int, string> >(db); Dictionary <int, DBElement <int, string> > dictFactory = new Dictionary <int, DBElement <int, string> >(); DBFactory <int, DBElement <int, string> > dbFactory; var keys = qEngine.getListKeyPattern(); if (keys != null) { foreach (var key in keys) { var val = db.getValueOfKey(key); dictFactory.Add(key, val); //add keys and values to the dictionary } dbFactory = new DBFactory <int, DBElement <int, string> >(dictFactory); //store the dictionary in the WriteLine("\nThe below key/value pairs with even keys pattern are saved as an immutable database\n"); dbFactory.showDB(); //display the immutable database WriteLine(); WriteLine(); } else { WriteLine("\nNo keys are obtained from a query for creation of immutable database\n"); } WriteLine(); WriteLine(); } catch (Exception e) { Console.WriteLine("\n" + e.Message + "\n"); } }
static void Main(string[] args) { QueryEngine <int, string> QE = new QueryEngine <int, string>(); QueryEngine <string, string> QE1 = new QueryEngine <string, string>(); DBEngine <int, DBElement <int, List <string> > > dbPay = new DBEngine <int, DBElement <int, List <string> > >(); DBEngine <string, DBElement <string, List <string> > > dbString = new DBEngine <string, DBElement <string, List <string> > >(); DBElement <string, List <String> > elemString = new DBElement <string, List <String> >(); //Populating DBEngine elemString.name = "Element2"; //object dbString elemString.descr = "testelement2"; //for testing data string and list of string type. elemString.timeStamp = DateTime.Now; elemString.children.AddRange(new List <string> { "SMA1", "Syracuse2", "NY3" }); elemString.payload = new List <string>(); elemString.payload.AddRange(new List <string> { "we", "rock", "the ", "world" }); dbString.insert("Prohject2", elemString); DBElement <string, List <String> > elemString2 = new DBElement <string, List <String> >(); //Populating DBEngine elemString2.name = "Element3"; //object dbString elemString2.descr = "test element3"; //for testing data string and list of string type. elemString2.timeStamp = DateTime.Now; elemString2.children.AddRange(new List <string> { "SMA2", "Syracuse22", "NY33" }); elemString2.payload = new List <string>(); elemString2.payload.AddRange(new List <string> { "Thug", "Life" }); dbString.insert("Thug3", elemString2); DBElement <int, List <string> > elemPayload = new DBElement <int, List <string> >(); //Populating DBEngine elemPayload.name = "Element4"; //object dbPay elemPayload.descr = "test element4"; //for testing data int and list of string type. elemPayload.timeStamp = DateTime.Now; elemPayload.children.AddRange(new List <int> { 1, 2, 3 }); elemPayload.payload = new List <string>(); elemPayload.payload.AddRange(new List <string> { "Project 2", " ", "demo", " ", "starts" }); dbPay.insert(1, elemPayload); DBElement <int, List <string> > elemPayload2 = new DBElement <int, List <string> >(); //Populating DBEngine elemPayload2.name = "Element5"; //object dbPay elemPayload2.descr = "test element5"; //for testing data int and list of string type. elemPayload2.timeStamp = DateTime.Now; elemPayload2.children.AddRange(new List <int> { 98, 22, 35 }); elemPayload2.payload = new List <string>(); elemPayload2.payload.AddRange(new List <string> { "we", "rock", "the", "world" }); dbPay.insert(2, elemPayload2); QE.valueByKey(1, dbPay); WriteLine(); QE.childrenByKey(1, dbPay); //QE1.keyPattern(".*h.*", dbString); WriteLine(); QE1.keyPattern(".*hjbbj.*", dbString); WriteLine(); QE.metaDataPattern("t2", dbString); //DateTime toDate = new DateTime(2015, 10, 7); DateTime toDate = new DateTime(2015, 10, 7); DateTime fromDate = new DateTime(2015, 10, 1); //System.Threading.Thread.Sleep(500); QE.dateTimeSearch(fromDate, toDate, dbString); }
static void Main(string[] args) { "Testing ItemEditor Package".title('='); Console.WriteLine(); DBEngine <int, DBElement <int, string> > db = new DBEngine <int, DBElement <int, string> >(); DBElement <int, string> elem1 = new DBElement <int, string>(); elem1.name = "India"; elem1.descr = "Country"; elem1.timeStamp = DateTime.Now; elem1.children.AddRange(new List <int> { 2, 3 }); elem1.payload = "Famous cricket player"; db.insert(1, elem1); DBElement <int, string> elem2 = new DBElement <int, string>(); //Add new key/value pairs to the database elem2.name = "Roger federer"; elem2.descr = "Tennis player"; elem2.timeStamp = DateTime.Now.AddDays(-15); elem2.children.AddRange(new List <int> { 3 }); elem2.payload = "Famous tennis player"; db.insert(2, elem2); DBElement <int, string> elem3 = new DBElement <int, string>(); elem3.name = "Usain Bolt"; elem3.descr = "Athelte"; elem3.timeStamp = DateTime.Now; elem3.children.AddRange(new List <int> { 1 }); elem3.payload = "Fastest in the world"; db.insert(3, elem3); Console.WriteLine(); db.showDB(); "\n1) Fetch Value for key 3".title(); var val = db.getValueOfKey(3); val.showElement(); Console.WriteLine(); QueryEngine <int, DBElement <int, string> > qEngine = new QueryEngine <int, DBElement <int, string> >(db); "\n2) Fetch the children of key 1".title(); var children = qEngine.getChildrenOfKey(1); displayChildren(children); DBEngine <string, DBElement <string, List <string> > > db2 = new DBEngine <string, DBElement <string, List <string> > >(); "\n 3) Fetch the keys which starts with r in the below database with key/value pairs".title(); //Taking new database with string keys DBElement <string, List <string> > elem4 = new DBElement <string, List <string> >(); elem4.name = "Christ college"; elem4.descr = "College where the person studied"; elem4.timeStamp = DateTime.Now; elem4.children.AddRange(new List <string> { "rakesh" }); elem4.payload = new List <string> { "One", "Two", "Three", "Four" }; db2.insert("saahith", elem4); DBElement <string, List <string> > elem5 = new DBElement <string, List <string> >(); elem5.name = "PESIT college"; elem5.descr = "College where the person pursued undergraduation"; elem5.timeStamp = DateTime.Now.AddDays(-2); elem5.children.AddRange(new List <string> { "saahith" }); elem5.payload = new List <string> { "Five", "Six", "Seven", "Eight" }; db2.insert("rakesh", elem5); db2.showEnumerableDB(); WriteLine(); QueryEngine <string, DBElement <string, List <string> > > qEngine2 = new QueryEngine <string, DBElement <string, List <string> > >(db2); string pattern1 = @"(^r)"; var spKeys = qEngine2.getListStringKeyPattern(pattern1); displayStringKeys(spKeys); "\n4) Fetch keys with metadata pattern 'Country'".title(); string pattern = "Country"; var mdKeys = qEngine.getListMetaDataPattern(pattern); displayKeys(mdKeys); "\n5) Fetch keys which are created between two dates 29th sept 2015 and 15th oct 2015".title(); DateTime time1 = new DateTime(2015, 9, 29); DateTime time2 = new DateTime(2015, 10, 15); var tpKeys = qEngine.getListTimePattern(time1, time2); displayKeys(tpKeys); }