public static void Run() { Console.WriteLine("Loading from File Store..."); var clients = new BiggyList <Client>(new JsonStore <Client>("clients")); clients.Clear(); var sw = new Stopwatch(); // Write a modest-sized batch to a file: int SMALL_BATCH_QTY = 1000; Console.WriteLine("Write {0} documents", SMALL_BATCH_QTY); var addRange = new List <Client>(); for (int i = 0; i < SMALL_BATCH_QTY; i++) { addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clients.Add(addRange); sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds); int LARGE_BATCH_QTY = 100000; Console.WriteLine("Write {0} documents", LARGE_BATCH_QTY); sw.Reset(); clients.Clear(); // Write a Bigger-sized batch to a file: // Reset the temp List; addRange = new List <Client>(); for (int i = 0; i < LARGE_BATCH_QTY; i++) { addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clients.Add(addRange); sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); Console.WriteLine("Querying Middle 400 Documents"); var found = clients.Where(x => x.ClientId > 100 && x.ClientId < 500); sw.Stop(); Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds); }
public static void Run() { Console.WriteLine("Loading from File Store..."); var clients = new BiggyList<Client>(new JsonStore<Client>("clients")); clients.Clear(); var sw = new Stopwatch(); // Write a modest-sized batch to a file: int SMALL_BATCH_QTY = 1000; Console.WriteLine("Write {0} documents", SMALL_BATCH_QTY); var addRange = new List<Client>(); for (int i = 0; i < SMALL_BATCH_QTY; i++) { addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clients.Add(addRange); sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds); int LARGE_BATCH_QTY = 100000; Console.WriteLine("Write {0} documents", LARGE_BATCH_QTY); sw.Reset(); clients.Clear(); // Write a Bigger-sized batch to a file: // Reset the temp List; addRange = new List<Client>(); for (int i = 0; i < LARGE_BATCH_QTY; i++) { addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clients.Add(addRange); sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); Console.WriteLine("Querying Middle 400 Documents"); var found = clients.Where(x => x.ClientId > 100 && x.ClientId < 500); sw.Stop(); Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds); }
public void Adds_Item_To_List_And_Store() { // Just in case: _clients.Clear(); var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }; _clients.Add(newClient); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList<Client>(_clientStore); Assert.True(altClientList.Count() > 0); }
public static void Run() { Console.WriteLine("Loading from File Store..."); var monkies = new BiggyList <Monkey>(); monkies.Clear(); var sw = new Stopwatch(); Console.WriteLine("Loading 10,000 documents"); sw.Start(); var addRange = new List <Monkey>(); for (int i = 0; i < 10000; i++) { monkies.Add(new Monkey { ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Loading 100,000 documents"); sw.Reset(); monkies.Clear(); sw.Start(); for (int i = 0; i < 100000; i++) { monkies.Add(new Monkey { ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count, sw.ElapsedMilliseconds); //use a DB that has an int PK sw.Reset(); sw.Start(); Console.WriteLine("Loading {0}...", monkies.Count); monkies.Reload(); sw.Stop(); Console.WriteLine("Loaded {0} documents from Postgres in {1}ms", monkies.Count, sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); Console.WriteLine("Querying Middle 100 Documents"); var found = monkies.Where(x => x.ID > 100 && x.ID < 500); sw.Stop(); Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds); }
public void Adds_Batch_Of_Items_To_Store() { _biggyWidgetList.Clear(); int INSERT_QTY = 100; var batch = new List<Widget>(); for (int i = 0; i < INSERT_QTY; i++) { batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = 2.00M }); } _biggyWidgetList.Add(batch); // Reload the List: var itemsInStore = new BiggyList<Widget>(_widgets); Assert.True(itemsInStore.Count() == INSERT_QTY); }
public void Bulk_Inserts_Documents_With_String_PK() { int INSERT_QTY = 100; var addRange = new List<MonkeyDocument>(); for (int i = 0; i < INSERT_QTY; i++) { addRange.Add(new MonkeyDocument { Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } IBiggyStore<MonkeyDocument> monkeyDocuments = new SqlCeDocumentStore<MonkeyDocument>(_connectionStringName); var inserted = monkeyDocuments.Add(addRange); // Reload, make sure everything was persisted: var monkeys = new BiggyList<MonkeyDocument>(new SqlCeDocumentStore<MonkeyDocument>(_connectionStringName)); Assert.True(monkeys.Count() == INSERT_QTY); }
public void Adds_Item_To_List_And_Store() { // Just in case: _clients.Clear(); var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }; _clients.Add(newClient); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList <Client>(new PGStore <Client>(_connectionStringName)); Assert.True(altClientList.Count() > 0); }
public void Adds_Many_Items_To_List_And_Store() { int INSERT_QTY = 10; // Just in case: _clients.Clear(); var addThese = new List<Client>(); for (int i = 0; i < INSERT_QTY; i++) { var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" }; addThese.Add(newClient); } _clients.Add(addThese); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList<Client>(_clientStore); Assert.True(altClientList.Count() == INSERT_QTY); }
public static void Run() { Console.WriteLine("Loading from File Store..."); var monkies = new BiggyList<Monkey>(); monkies.Clear(); var sw = new Stopwatch(); Console.WriteLine("Loading 10,000 documents"); sw.Start(); var addRange = new List<Monkey>(); for (int i = 0; i < 10000; i++) { monkies.Add(new Monkey {ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Loading 100,000 documents"); sw.Reset(); monkies.Clear(); sw.Start(); for (int i = 0; i < 100000; i++) { monkies.Add(new Monkey { ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } sw.Stop(); Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count, sw.ElapsedMilliseconds); //use a DB that has an int PK sw.Reset(); sw.Start(); Console.WriteLine("Loading {0}...", monkies.Count); monkies.Reload(); sw.Stop(); Console.WriteLine("Loaded {0} documents from Postgres in {1}ms", monkies.Count, sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); Console.WriteLine("Querying Middle 100 Documents"); var found = monkies.Where(x => x.ID > 100 && x.ID < 500); sw.Stop(); Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds); }
public void Bulk_Inserts_Documents_With_String_PK() { int INSERT_QTY = 100; var addRange = new List <MonkeyDocument>(); for (int i = 0; i < INSERT_QTY; i++) { addRange.Add(new MonkeyDocument { Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" }); } IBiggyStore <MonkeyDocument> monkeyDocuments = new SqlCeDocumentStore <MonkeyDocument>(_connectionStringName); var inserted = monkeyDocuments.Add(addRange); // Reload, make sure everything was persisted: var monkeys = new BiggyList <MonkeyDocument>(new SqlCeDocumentStore <MonkeyDocument>(_connectionStringName)); Assert.True(monkeys.Count() == INSERT_QTY); }
public void Adds_Batch_Of_Items_To_Store() { _biggyWidgetList.Clear(); int INSERT_QTY = 100; var batch = new List <Widget>(); for (int i = 0; i < INSERT_QTY; i++) { batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = 2.00M }); } _biggyWidgetList.Add(batch); // Reload the List: var itemsInStore = new BiggyList <Widget>(_widgets); Assert.True(itemsInStore.Count() == INSERT_QTY); }
public void Removes_Item_From_List_And_Store() { // Just in case: _clients.Clear(); var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }; _clients.Add(newClient); int firstCount = _clients.Count(); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList <Client>(new PGStore <Client>(_connectionStringName)); var deleteMe = altClientList.FirstOrDefault(); altClientList.Remove(deleteMe); Assert.True(firstCount > 0 && altClientList.Count() == 0); }
//Add Serie public Serie AddSerie(string serie, out bool isAddResult) { Serie newSerie = new Serie(); int exist = _serieList.Count(c => c.SerieName == serie); if (exist < 1) { newSerie.SerieId = Guid.NewGuid().ToString(); newSerie.SerieName = serie; newSerie.SerieSeasson = 1; newSerie.SerieEpisode = 1; _serieList.Add(newSerie); isAddResult = true; } else { isAddResult = false; } return(newSerie); }
public void Adds_Many_Items_To_List_And_Store() { int INSERT_QTY = 10; // Just in case: _clients.Clear(); var addThese = new List <Client>(); for (int i = 0; i < INSERT_QTY; i++) { var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" }; addThese.Add(newClient); } _clients.Add(addThese); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList <Client>(new PGStore <Client>(_connectionStringName)); Assert.True(altClientList.Count() == INSERT_QTY); }
public static void Run() { var sw = new Stopwatch(); Console.WriteLine("==========================================================="); Console.WriteLine("Postgres - SOME FANCY QUERYING"); Console.WriteLine("==========================================================="); var _db = new PGCache(_connectionStringName); IBiggy<Artist> _artists; IBiggy<Album> _albums; IBiggy<Track> _tracks; Console.WriteLine("Loading up Artists from Chinook..."); sw.Start(); _artists = new BiggyList<Artist>(new PGStore<Artist>(_db)); sw.Stop(); Console.WriteLine("\tLoaded {0} Artist records in {1} ms", _artists.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Loading up Albums from Chinook..."); sw.Reset(); sw.Start(); _albums = new BiggyList<Album>(new PGStore<Album>(_db)); sw.Stop(); Console.WriteLine("\tLoaded {0} Albums in {1} ms", _artists.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Loading up tracks from Chinook..."); sw.Reset(); sw.Start(); _tracks = new BiggyList<Track>(new PGStore<Track>(_db)); sw.Stop(); Console.WriteLine("\tLoaded {0} Tracks in {1} ms", _tracks.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Grab the record for AC/DC..."); sw.Reset(); sw.Start(); var acdc = _artists.FirstOrDefault(a => a.Name == "AC/DC"); sw.Stop(); Console.WriteLine("\tFound AC/DC from memory in {0} ms", sw.ElapsedMilliseconds); Console.WriteLine("Find all the albums by AC/DC ..."); sw.Reset(); sw.Start(); var acdcAlbums = _albums.Where(a => a.ArtistId == acdc.ArtistId); sw.Stop(); Console.WriteLine("\tFound All {0} AC/DC albums from memory in {1} ms", acdcAlbums.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Find all the Tracks from Albums by AC/DC ..."); sw.Reset(); sw.Start(); var acdcTracks = from t in _tracks join a in acdcAlbums on t.AlbumId equals a.AlbumId select t; sw.Stop(); Console.WriteLine("\tFound All {0} tracks by ACDC using in-memory JOIN in {1} ms:", acdcTracks.Count(), sw.ElapsedMilliseconds); foreach (var track in acdcTracks) { Console.WriteLine("\t-{0}", track.Name); } Console.WriteLine(Environment.NewLine); Console.WriteLine("==========================================================="); Console.WriteLine("POSTGES - BASIC CRUD OPERATIONS"); Console.WriteLine("==========================================================="); IBiggy<Customer> _customers; sw.Reset(); Console.WriteLine("Loading up customers from Chinook..."); sw.Start(); _customers = new BiggyList<Customer>(new PGStore<Customer>(_db)); sw.Stop(); Console.WriteLine("\tLoaded {0} records in {1}ms", _customers.Count(), sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("INSERTING a NEW Customer into Chinook..."); var newCustomer = new Customer() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }; sw.Start(); _customers.Add(newCustomer); sw.Stop(); Console.WriteLine("\tWrote 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("UPDATING the new Customer record in Chinook..."); newCustomer.FirstName = "Fred"; sw.Start(); _customers.Update(newCustomer); sw.Stop(); Console.WriteLine("\tUpdated 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("DELETE the new Customer record in Chinook..."); sw.Start(); _customers.Remove(newCustomer); sw.Stop(); Console.WriteLine("\tDeleted 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds); Console.WriteLine(Environment.NewLine); Console.WriteLine("==========================================================="); Console.WriteLine("POSTGES - BULK INSERTS AND DELETIONS"); Console.WriteLine("==========================================================="); Console.WriteLine("Creating Test Table..."); if(_db.TableExists("client")) { _db.DropTable("client"); } var columnDefs = new List<string>(); columnDefs.Add("client_id serial PRIMARY KEY NOT NULL"); columnDefs.Add("last_name Text NOT NULL"); columnDefs.Add("first_name Text NOT NULL"); columnDefs.Add("email Text NOT NULL"); _db.CreateTable("client", columnDefs); IBiggy<Client> _clients; sw.Reset(); int INSERT_QTY = 10000; Console.WriteLine("BULK INSERTING {0} client records in Chinook...", INSERT_QTY); _clients = new BiggyList<Client>(new PGStore<Client>(_db)); var inserts = new List<Client>(); for (int i = 0; i < INSERT_QTY; i++) { inserts.Add(new Client() { LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); var inserted = _clients.Add(inserts); sw.Stop(); Console.WriteLine("\tInserted {0} records in {1} ms", inserted.Count(), sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Loading up Bulk inserted CLients from Chinook..."); sw.Start(); _clients = new BiggyList<Client>(new PGStore<Client>(_db)); sw.Stop(); Console.WriteLine("\tLoaded {0} records in {1}ms", _clients.Count(), sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("DELETING added records from Chinook..."); var toRemove = _clients.Where(x => x.Email == "*****@*****.**"); sw.Start(); var removed = _clients.Remove(toRemove.ToList()); sw.Stop(); Console.WriteLine("\tDeleted {0} records in {1}ms", removed.Count(), sw.ElapsedMilliseconds); }
public void Initializes_Memory_Only_List_With_True_Argument() { _biggyMemoryList = new BiggyList<Widget>(inMemory: true); var BiggyJsonList = new BiggyList<Widget>(); _biggyMemoryList.Clear(); BiggyJsonList.Clear(); var batch = new List<Widget>(); for (int i = 0; i < INSERT_QTY; i++) { batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i }); } _biggyMemoryList.Add(batch); BiggyJsonList.Add(batch); int memoryCount = _biggyMemoryList.Count(); _biggyMemoryList.Clear(); BiggyJsonList = new BiggyList<Widget>(); Assert.True(memoryCount == INSERT_QTY && _biggyMemoryList.Count() == 0 && BiggyJsonList.Count() == INSERT_QTY); }
public static void Run() { var sw = new Stopwatch(); Console.WriteLine("==========================================================="); Console.WriteLine("Postgres - SOME FANCY QUERYING"); Console.WriteLine("==========================================================="); var _db = new PGCache(_connectionStringName); IBiggy <Artist> _artists; IBiggy <Album> _albums; IBiggy <Track> _tracks; Console.WriteLine("Loading up Artists from Chinook..."); sw.Start(); _artists = new BiggyList <Artist>(new PGStore <Artist>(_db)); sw.Stop(); Console.WriteLine("\tLoaded {0} Artist records in {1} ms", _artists.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Loading up Albums from Chinook..."); sw.Reset(); sw.Start(); _albums = new BiggyList <Album>(new PGStore <Album>(_db)); sw.Stop(); Console.WriteLine("\tLoaded {0} Albums in {1} ms", _artists.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Loading up tracks from Chinook..."); sw.Reset(); sw.Start(); _tracks = new BiggyList <Track>(new PGStore <Track>(_db)); sw.Stop(); Console.WriteLine("\tLoaded {0} Tracks in {1} ms", _tracks.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Grab the record for AC/DC..."); sw.Reset(); sw.Start(); var acdc = _artists.FirstOrDefault(a => a.Name == "AC/DC"); sw.Stop(); Console.WriteLine("\tFound AC/DC from memory in {0} ms", sw.ElapsedMilliseconds); Console.WriteLine("Find all the albums by AC/DC ..."); sw.Reset(); sw.Start(); var acdcAlbums = _albums.Where(a => a.ArtistId == acdc.ArtistId); sw.Stop(); Console.WriteLine("\tFound All {0} AC/DC albums from memory in {1} ms", acdcAlbums.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Find all the Tracks from Albums by AC/DC ..."); sw.Reset(); sw.Start(); var acdcTracks = from t in _tracks join a in acdcAlbums on t.AlbumId equals a.AlbumId select t; sw.Stop(); Console.WriteLine("\tFound All {0} tracks by ACDC using in-memory JOIN in {1} ms:", acdcTracks.Count(), sw.ElapsedMilliseconds); foreach (var track in acdcTracks) { Console.WriteLine("\t-{0}", track.Name); } Console.WriteLine(Environment.NewLine); Console.WriteLine("==========================================================="); Console.WriteLine("POSTGES - BASIC CRUD OPERATIONS"); Console.WriteLine("==========================================================="); IBiggy <Customer> _customers; sw.Reset(); Console.WriteLine("Loading up customers from Chinook..."); sw.Start(); _customers = new BiggyList <Customer>(new PGStore <Customer>(_db)); sw.Stop(); Console.WriteLine("\tLoaded {0} records in {1}ms", _customers.Count(), sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("INSERTING a NEW Customer into Chinook..."); var newCustomer = new Customer() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }; sw.Start(); _customers.Add(newCustomer); sw.Stop(); Console.WriteLine("\tWrote 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("UPDATING the new Customer record in Chinook..."); newCustomer.FirstName = "Fred"; sw.Start(); _customers.Update(newCustomer); sw.Stop(); Console.WriteLine("\tUpdated 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("DELETE the new Customer record in Chinook..."); sw.Start(); _customers.Remove(newCustomer); sw.Stop(); Console.WriteLine("\tDeleted 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds); Console.WriteLine(Environment.NewLine); Console.WriteLine("==========================================================="); Console.WriteLine("POSTGES - BULK INSERTS AND DELETIONS"); Console.WriteLine("==========================================================="); Console.WriteLine("Creating Test Table..."); if (_db.TableExists("client")) { _db.DropTable("client"); } var columnDefs = new List <string>(); columnDefs.Add("client_id serial PRIMARY KEY NOT NULL"); columnDefs.Add("last_name Text NOT NULL"); columnDefs.Add("first_name Text NOT NULL"); columnDefs.Add("email Text NOT NULL"); _db.CreateTable("client", columnDefs); IBiggy <Client> _clients; sw.Reset(); int INSERT_QTY = 10000; Console.WriteLine("BULK INSERTING {0} client records in Chinook...", INSERT_QTY); _clients = new BiggyList <Client>(new PGStore <Client>(_db)); var inserts = new List <Client>(); for (int i = 0; i < INSERT_QTY; i++) { inserts.Add(new Client() { LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); var inserted = _clients.Add(inserts); sw.Stop(); Console.WriteLine("\tInserted {0} records in {1} ms", inserted.Count(), sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("Loading up Bulk inserted CLients from Chinook..."); sw.Start(); _clients = new BiggyList <Client>(new PGStore <Client>(_db)); sw.Stop(); Console.WriteLine("\tLoaded {0} records in {1}ms", _clients.Count(), sw.ElapsedMilliseconds); sw.Reset(); Console.WriteLine("DELETING added records from Chinook..."); var toRemove = _clients.Where(x => x.Email == "*****@*****.**"); sw.Start(); var removed = _clients.Remove(toRemove.ToList()); sw.Stop(); Console.WriteLine("\tDeleted {0} records in {1}ms", removed.Count(), sw.ElapsedMilliseconds); }
public void Initializes_Memory_Only_List_With_True_Argument() { _biggyMemoryList = new BiggyList <Widget>(inMemory: true); var BiggyJsonList = new BiggyList <Widget>(); _biggyMemoryList.Clear(); BiggyJsonList.Clear(); var batch = new List <Widget>(); for (int i = 0; i < INSERT_QTY; i++) { batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i }); } _biggyMemoryList.Add(batch); BiggyJsonList.Add(batch); int memoryCount = _biggyMemoryList.Count(); _biggyMemoryList.Clear(); BiggyJsonList = new BiggyList <Widget>(); Assert.True(memoryCount == INSERT_QTY && _biggyMemoryList.Count() == 0 && BiggyJsonList.Count() == INSERT_QTY); }
public void Removes_Item_From_List_And_Store() { // Just in case: _clients.Clear(); var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }; _clients.Add(newClient); int firstCount = _clients.Count(); // Open a new instance, to see if the item was added to the backing store as well: var altClientList = new BiggyList<Client>(_clientStore); var deleteMe = altClientList.FirstOrDefault(); altClientList.Remove(deleteMe); Assert.True(firstCount > 0 && altClientList.Count() == 0); }
public static void Run() { var sw = new Stopwatch(); var _myDatabase = new SQLServerCache("chinook"); Console.WriteLine("==========================================================="); Console.WriteLine("SQL SERVER DOCUMENTS - INSERT A BUNCH OF DOCUMENTS"); Console.WriteLine("==========================================================="); // Build a table to play with from scratch each time: if (_myDatabase.TableExists("ClientDocuments")) { _myDatabase.DropTable("ClientDocuments"); } IBiggyStore <ClientDocument> clientDocStore = new SQLDocumentStore <ClientDocument>("chinook"); IBiggy <ClientDocument> clientDocs = new BiggyList <ClientDocument>(clientDocStore); int INSERT_MODEST_QTY = 10000; Console.WriteLine("Insert {0} records as documents...", INSERT_MODEST_QTY); var addThese = new List <ClientDocument>(); for (int i = 0; i < INSERT_MODEST_QTY; i++) { addThese.Add(new ClientDocument { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clientDocs.Add(addThese); sw.Stop(); Console.WriteLine("Inserted {0} records as documents in {1} ms", INSERT_MODEST_QTY, sw.ElapsedMilliseconds); Console.WriteLine("==========================================================="); Console.WriteLine("SQL SERVER DOCUMENTS - SOME FANCY COMPLEX DOCUMENT STUFF"); Console.WriteLine("==========================================================="); // Start clean with no existing table: var temp = new SQLServerCache("chinook"); if (temp.TableExists("ArtistWithAlbums")) { temp.DropTable("ArtistWithAlbums"); } Console.WriteLine("Retreive artists, albums, and tracks from Db..."); sw.Reset(); sw.Start(); IBiggyStore <Artist> _artistStore = new SQLServerStore <Artist>(_myDatabase); IBiggyStore <Album> _albumStore = new SQLServerStore <Album>(_myDatabase); IBiggyStore <Track> _trackStore = new SQLServerStore <Track>(_myDatabase); IBiggy <Artist> _artists = new BiggyList <Artist>(_artistStore); IBiggy <Album> _albums = new BiggyList <Album>(_albumStore); IBiggy <Track> _tracks = new BiggyList <Track>(_trackStore); sw.Stop(); Console.WriteLine("Query each artists albums and write to complex document store..."); var list = new List <ArtistWithAlbums>(); foreach (var artist in _artists) { var artistAlbums = from a in _albums where a.ArtistId == artist.ArtistId select a; var newArtistWithAlbums = new ArtistWithAlbums() { ArtistId = artist.ArtistId, Name = artist.Name, Albums = artistAlbums.ToList() }; list.Add(newArtistWithAlbums); } var docStore = new SQLDocumentStore <ArtistWithAlbums>(_myDatabase); var artistWithAlbumsDocuments = new BiggyList <ArtistWithAlbums>(docStore); artistWithAlbumsDocuments.Add(list); sw.Stop(); Console.WriteLine("Added {0} Artist + Album records as complex documents in {1} ms", _artists.Count(), sw.ElapsedMilliseconds); //Console.WriteLine("Retreive artists and albums from Complex document store and hydrate"); //// Re-hydrate the store, just to be sure: //_myDatabase = new SQLServerHost("chinook"); //sw.Reset(); //sw.Start(); //artistWithAlbumsDocuments = new BiggyList<ArtistWithAlbums>(docStore); //foreach (var artist in artistWithAlbumsDocuments) { // Console.WriteLine("\t{0}", artist.Name); // var albumNames = from a in artist.Albums select a.Title; // foreach (string name in albumNames) { // string useName = name; // if (name.Length > 10) { // useName = name.Remove(10, name.Length - 10); // } // Console.WriteLine("\t\t{0} ...", useName); // } //} //sw.Stop(); //Console.WriteLine("\tRetreived and Re-Hydrated/wrote to console {0} Artist + Album records from complex documents in {1} ms", _artists.Count(), sw.ElapsedMilliseconds); }
public static void Run() { var sw = new Stopwatch(); var _myDatabase = new SQLServerCache("chinook"); Console.WriteLine("==========================================================="); Console.WriteLine("SQL SERVER DOCUMENTS - INSERT A BUNCH OF DOCUMENTS"); Console.WriteLine("==========================================================="); // Build a table to play with from scratch each time: if(_myDatabase.TableExists("ClientDocuments")) { _myDatabase.DropTable("ClientDocuments"); } IBiggyStore<ClientDocument> clientDocStore = new SQLDocumentStore<ClientDocument>("chinook"); IBiggy<ClientDocument> clientDocs = new BiggyList<ClientDocument>(clientDocStore); int INSERT_MODEST_QTY = 10000; Console.WriteLine("Insert {0} records as documents...", INSERT_MODEST_QTY); var addThese = new List<ClientDocument>(); for(int i = 0; i < INSERT_MODEST_QTY; i++) { addThese.Add(new ClientDocument { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clientDocs.Add(addThese); sw.Stop(); Console.WriteLine("Inserted {0} records as documents in {1} ms", INSERT_MODEST_QTY, sw.ElapsedMilliseconds); Console.WriteLine("==========================================================="); Console.WriteLine("SQL SERVER DOCUMENTS - SOME FANCY COMPLEX DOCUMENT STUFF"); Console.WriteLine("==========================================================="); // Start clean with no existing table: var temp = new SQLServerCache("chinook"); if (temp.TableExists("ArtistWithAlbums")) { temp.DropTable("ArtistWithAlbums"); } Console.WriteLine("Retreive artists, albums, and tracks from Db..."); sw.Reset(); sw.Start(); IBiggyStore<Artist> _artistStore = new SQLServerStore<Artist>(_myDatabase); IBiggyStore<Album> _albumStore = new SQLServerStore<Album>(_myDatabase); IBiggyStore<Track> _trackStore = new SQLServerStore<Track>(_myDatabase); IBiggy<Artist> _artists = new BiggyList<Artist>(_artistStore); IBiggy<Album> _albums = new BiggyList<Album>(_albumStore); IBiggy<Track> _tracks = new BiggyList<Track>(_trackStore); sw.Stop(); Console.WriteLine("Query each artists albums and write to complex document store..."); var list = new List<ArtistWithAlbums>(); foreach (var artist in _artists) { var artistAlbums = from a in _albums where a.ArtistId == artist.ArtistId select a; var newArtistWithAlbums = new ArtistWithAlbums() { ArtistId = artist.ArtistId, Name = artist.Name, Albums = artistAlbums.ToList() }; list.Add(newArtistWithAlbums); } var docStore = new SQLDocumentStore<ArtistWithAlbums>(_myDatabase); var artistWithAlbumsDocuments = new BiggyList<ArtistWithAlbums>(docStore); artistWithAlbumsDocuments.Add(list); sw.Stop(); Console.WriteLine("Added {0} Artist + Album records as complex documents in {1} ms", _artists.Count(), sw.ElapsedMilliseconds); //Console.WriteLine("Retreive artists and albums from Complex document store and hydrate"); //// Re-hydrate the store, just to be sure: //_myDatabase = new SQLServerHost("chinook"); //sw.Reset(); //sw.Start(); //artistWithAlbumsDocuments = new BiggyList<ArtistWithAlbums>(docStore); //foreach (var artist in artistWithAlbumsDocuments) { // Console.WriteLine("\t{0}", artist.Name); // var albumNames = from a in artist.Albums select a.Title; // foreach (string name in albumNames) { // string useName = name; // if (name.Length > 10) { // useName = name.Remove(10, name.Length - 10); // } // Console.WriteLine("\t\t{0} ...", useName); // } //} //sw.Stop(); //Console.WriteLine("\tRetreived and Re-Hydrated/wrote to console {0} Artist + Album records from complex documents in {1} ms", _artists.Count(), sw.ElapsedMilliseconds); }
public static void Run() { var sw = new Stopwatch(); var _myDatabase = new PGCache("chinookPG"); Console.WriteLine("==========================================================="); Console.WriteLine("POSTGRES DOCUMENTS - INSERT A BUNCH OF DOCUMENTS"); Console.WriteLine("==========================================================="); // Build a table to play with from scratch each time: if(_myDatabase.TableExists("ClientDocuments")) { _myDatabase.DropTable("\"ClientDocuments\""); } IBiggyStore<ClientDocument> clientDocStore = new PGDocumentStore<ClientDocument>(_myDatabase); IBiggy<ClientDocument> clientDocs = new BiggyList<ClientDocument>(clientDocStore); int INSERT_MODEST_QTY = 10000; Console.WriteLine("Insert {0} records as documents...", INSERT_MODEST_QTY); var addThese = new List<ClientDocument>(); for(int i = 0; i < INSERT_MODEST_QTY; i++) { addThese.Add(new ClientDocument { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clientDocs.Add(addThese); sw.Stop(); Console.WriteLine("Inserted {0} records as documents in {1} ms", INSERT_MODEST_QTY, sw.ElapsedMilliseconds); Console.WriteLine("==========================================================="); Console.WriteLine("POSTGRES DOCUMENTS - SOME FANCY COMPLEX DOCUMENT STUFF"); Console.WriteLine("==========================================================="); // Start clean with no existing table: if (_myDatabase.TableExists("ArtistWithAlbums")) { _myDatabase.DropTable("\"ArtistWithAlbums\""); } Console.WriteLine("Retreive artists, albums, and tracks from Db..."); sw.Reset(); sw.Start(); IBiggyStore<Artist> _artistStore = new PGStore<Artist>(_myDatabase); IBiggyStore<Album> _albumStore = new PGStore<Album>(_myDatabase); IBiggyStore<Track> _trackStore = new PGStore<Track>(_myDatabase); IBiggy<Artist> _artists = new BiggyList<Artist>(_artistStore); IBiggy<Album> _albums = new BiggyList<Album>(_albumStore); IBiggy<Track> _tracks = new BiggyList<Track>(_trackStore); sw.Stop(); Console.WriteLine("Query each artists albums and write to complex document store..."); var list = new List<ArtistWithAlbums>(); foreach (var artist in _artists) { var artistAlbums = from a in _albums where a.ArtistId == artist.ArtistId select a; var newArtistWithAlbums = new ArtistWithAlbums() { ArtistId = artist.ArtistId, Name = artist.Name, Albums = artistAlbums.ToList() }; list.Add(newArtistWithAlbums); } var docStore = new PGDocumentStore<ArtistWithAlbums>(_myDatabase); var artistWithAlbumsDocuments = new BiggyList<ArtistWithAlbums>(docStore); artistWithAlbumsDocuments.Add(list); sw.Stop(); Console.WriteLine("Added {0} Artist + Album records as complex documents in {1} ms", _artists.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Retreive artists and albums from Complex document store and hydrate"); sw.Reset(); sw.Start(); artistWithAlbumsDocuments = new BiggyList<ArtistWithAlbums>(docStore); sw.Stop(); int artistCount = artistWithAlbumsDocuments.Count(); int albumsCount = 0; foreach (var artist in artistWithAlbumsDocuments) { albumsCount += artist.Albums.Count(); } Console.WriteLine("\tRetreived and Re-Hydrated {0} Artist + {1} Album records from complex documents in {2} ms", artistCount, albumsCount, sw.ElapsedMilliseconds); }
public static void Run() { var sw = new Stopwatch(); var _myDatabase = new PGCache("chinookPG"); Console.WriteLine("==========================================================="); Console.WriteLine("POSTGRES DOCUMENTS - INSERT A BUNCH OF DOCUMENTS"); Console.WriteLine("==========================================================="); // Build a table to play with from scratch each time: if (_myDatabase.TableExists("ClientDocuments")) { _myDatabase.DropTable("\"ClientDocuments\""); } IBiggyStore <ClientDocument> clientDocStore = new PGDocumentStore <ClientDocument>(_myDatabase); IBiggy <ClientDocument> clientDocs = new BiggyList <ClientDocument>(clientDocStore); int INSERT_MODEST_QTY = 10000; Console.WriteLine("Insert {0} records as documents...", INSERT_MODEST_QTY); var addThese = new List <ClientDocument>(); for (int i = 0; i < INSERT_MODEST_QTY; i++) { addThese.Add(new ClientDocument { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" }); } sw.Start(); clientDocs.Add(addThese); sw.Stop(); Console.WriteLine("Inserted {0} records as documents in {1} ms", INSERT_MODEST_QTY, sw.ElapsedMilliseconds); Console.WriteLine("==========================================================="); Console.WriteLine("POSTGRES DOCUMENTS - SOME FANCY COMPLEX DOCUMENT STUFF"); Console.WriteLine("==========================================================="); // Start clean with no existing table: if (_myDatabase.TableExists("ArtistWithAlbums")) { _myDatabase.DropTable("\"ArtistWithAlbums\""); } Console.WriteLine("Retreive artists, albums, and tracks from Db..."); sw.Reset(); sw.Start(); IBiggyStore <Artist> _artistStore = new PGStore <Artist>(_myDatabase); IBiggyStore <Album> _albumStore = new PGStore <Album>(_myDatabase); IBiggyStore <Track> _trackStore = new PGStore <Track>(_myDatabase); IBiggy <Artist> _artists = new BiggyList <Artist>(_artistStore); IBiggy <Album> _albums = new BiggyList <Album>(_albumStore); IBiggy <Track> _tracks = new BiggyList <Track>(_trackStore); sw.Stop(); Console.WriteLine("Query each artists albums and write to complex document store..."); var list = new List <ArtistWithAlbums>(); foreach (var artist in _artists) { var artistAlbums = from a in _albums where a.ArtistId == artist.ArtistId select a; var newArtistWithAlbums = new ArtistWithAlbums() { ArtistId = artist.ArtistId, Name = artist.Name, Albums = artistAlbums.ToList() }; list.Add(newArtistWithAlbums); } var docStore = new PGDocumentStore <ArtistWithAlbums>(_myDatabase); var artistWithAlbumsDocuments = new BiggyList <ArtistWithAlbums>(docStore); artistWithAlbumsDocuments.Add(list); sw.Stop(); Console.WriteLine("Added {0} Artist + Album records as complex documents in {1} ms", _artists.Count(), sw.ElapsedMilliseconds); Console.WriteLine("Retreive artists and albums from Complex document store and hydrate"); sw.Reset(); sw.Start(); artistWithAlbumsDocuments = new BiggyList <ArtistWithAlbums>(docStore); sw.Stop(); int artistCount = artistWithAlbumsDocuments.Count(); int albumsCount = 0; foreach (var artist in artistWithAlbumsDocuments) { albumsCount += artist.Albums.Count(); } Console.WriteLine("\tRetreived and Re-Hydrated {0} Artist + {1} Album records from complex documents in {2} ms", artistCount, albumsCount, sw.ElapsedMilliseconds); }