public void Init() { this.storage = new InMemoryStorage(); this.db = new DazzleDatabase(this.storage); this.Given(); this.When(); }
private static void Main(string[] args) { if (preload && Directory.Exists(path)) { Directory.Delete(path, true); } //using (var storage = new LevelDBStorage(path)) using (var storage = new InMemoryStorage()) using (var db = new DazzleDatabase(storage)) { if (preload) { PreloadData(storage); //ShowData(storage); } var result1 = ExecuteQuery(db, "select * from users where column0 = 'bob1' and column1 = 'bob1'"); var result2 = ExecuteQuery(db, "select * from users where column0 = 'bob1' and column1 = 'bob1'"); //var result2 = ExecuteQuery(db, "update users set column0 = 'bob8888', column1 = 'bob8888' where key = 1"); //var result3 = ExecuteQuery(db, "select * from users where column0 = 'bob9999' and column1 = 'bob9999'"); //var result2 = ExecuteQuery(db, "select column0, column1, column49 from users where column0 = 'bob1' and column1 = 'bob1'"); //var result2 = ExecuteQuery(db, "select * from users where column0 = 'bob1' and column1 = 'bob1'"); //var result2 = ExecuteQuery(db, "select * from users where column0 = 'bob1' and column49 = 'bob1'"); //var result3 = ExecuteQuery(db, "select column15 from users where column0 = 'bob1'"); //var result1 = ExecuteQuery(db, "select * from users where column0 = 'bob1'"); } //var client = new System.Net.Sockets.TcpClient(); //client.Connect("127.0.0.1", 5223); //string query = "select * from users where column49 = 'bob9000'"; //var data = new byte[query.Length + 3]; //data[0] = (byte)MessageType.Query; //var length = BitConverter.GetBytes(query.Length); //length.CopyTo(data, 1); //var queryBytes = UTF8Encoding.UTF8.GetBytes(query); //queryBytes.CopyTo(data, 3); //var buffer = new byte[1024]; //int count = 10000; //var watch = new Stopwatch(); //watch.Start(); //for (int i = 0; i < count; i++) //{ // client.Client.Send(data); // int read = client.Client.Receive(buffer); //} //watch.Stop(); //Console.WriteLine(count / watch.Elapsed.TotalSeconds); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this.disposed) { this.disposed = true; if (this.db != null) { this.db.Dispose(); this.db = null; } } }
private static QueryResult ExecuteQuery(DazzleDatabase db, string query) { Console.WriteLine(); Console.WriteLine("Query: " + query); var result = db.ExecuteQuery(query); if (result.Rows.Count > 0) { Console.WriteLine("Returned Rows: " + result.Rows.Count + " Columns per row: " + result.Rows[0].Columns.Count); } Console.WriteLine("Query executed in " + result.ExecutionTime); return(result); }
public DazzleServer(IStorage storage) : base(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5223)) { db = new DazzleDatabase(storage); }