void DeleteEachItem() { PeopleStoreByName.MoveFirst(); PersonKey pk; int Ctr = 0; long[] Pids = new long[1000]; int i = 0; bool personMissing = false; do { Ctr++; pk = PeopleStoreByName.CurrentKey; long PersonID = PeopleStoreByName.CurrentValue; Pids[i++] = PersonID; if (i == 1000) { //** query a thousand people... batching like this is optimal use of SOP container... QueryResult <long>[] People; foreach (var pid in Pids) { if (!PeopleStore.Remove(pid)) { personMissing = true; Assert.Fail("Person with ID {0} not found.", pid); } } i = 0; } } while (PeopleStoreByName.MoveNext()); if (i > 0) { QueryResult <long>[] People; long[] d = new long[i]; Array.Copy(Pids, 0, d, 0, i); foreach (var l in d) { if (!PeopleStore.Remove(l)) { personMissing = true; Assert.Fail("Person with ID {0} not found.", l); } } } if (personMissing) { Assert.Fail("Failed! Mising person detected."); return; } if (0 != PeopleStore.Count) { Assert.Fail("Failed! Read {0}, expected {1}", 0, PeopleStore.Count); } else { Console.WriteLine("Deleted {0} items on 2ndary store.", Ctr); } Ctr = 0; while (PeopleStoreByName.MoveFirst()) { Ctr++; pk = PeopleStoreByName.CurrentKey; PeopleStoreByName.Remove(); } Console.WriteLine("Deleted {0} items.", Ctr); }
void DeleteEachItem() { if (server.Transaction == null) { server.BeginTransaction(); } PeopleStoreByName.MoveFirst(); PeopleStoreByName.HintBatchCount = 303; PersonKey pk; int Ctr = 0; long[] Pids = new long[1000]; int i = 0; bool personMissing = false; do { Ctr++; pk = PeopleStoreByName.CurrentKey; long PersonID = PeopleStoreByName.CurrentValue; Pids[i++] = PersonID; if (i == 1000) { //** query a thousand people... batching like this is optimal use of SOP container... QueryResult <long>[] People; if (PeopleStore.Remove(QueryExpression <long> .Package(Pids), out People)) { foreach (var p in People) { if (!p.Found) { personMissing = true; Assert.Fail("Person with ID {0} not found.", p.Key); } } } else { Assert.Fail("Failed to Remove a 1,000 people starting with PID {0}.", Pids[0]); } i = 0; } } while (PeopleStoreByName.MoveNext()); if (i > 0) { QueryResult <long>[] People; long[] d = new long[i]; Array.Copy(Pids, 0, d, 0, i); if (PeopleStore.Remove(QueryExpression <long> .Package(d), out People)) { foreach (var p in People) { if (!p.Found) { personMissing = true; Assert.Fail("Person with ID {0} not found.", p.Key); } } } } if (personMissing) { Assert.Fail("Failed! Mising person detected."); return; } if (Ctr != MaxCount) { Assert.Fail("Failed! Deleted {0}, expected {1}", Ctr, MaxCount); } else { Console.WriteLine("Deleted {0} items on 2ndary store.", Ctr); } Ctr = 0; while (PeopleStoreByName.MoveFirst()) { Ctr++; pk = PeopleStoreByName.CurrentKey; PeopleStoreByName.Remove(); } Console.WriteLine("Deleted {0} items.", Ctr); server.Commit(); }