void ReadAll() { 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.Search(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.Search(l)) { personMissing = true; Assert.Fail("Person with ID {0} not found.", l); } } } if (personMissing) { Assert.Fail("Failed! Mising person detected."); return; } if (Ctr != PeopleStore.Count) { Assert.Fail("Failed! Read {0}, expected {1}", Ctr, PeopleStore.Count); } else { Console.WriteLine("Read {0} items.", Ctr); } }
void ReadAll() { PeopleStoreByName.MoveFirst(); PeopleStoreByName.HintBatchCount = 103; long[] Pids = new long[BatchCount]; int PidsIndex = 0; PersonKey[] pk = new PersonKey[BatchCount]; int Ctr = 0; do { Ctr++; pk[PidsIndex++] = PeopleStoreByName.CurrentKey; if (PidsIndex == BatchCount) { QueryResult <PersonKey>[] PeopleIDs; if (PeopleStoreByName.Query(QueryExpression <PersonKey> .Package(pk), out PeopleIDs)) { for (int i = 0; i < PeopleIDs.Length; i++) { Pids[i] = (long)PeopleIDs[i].Value; } QueryResult <long>[] PeopleFound; if (PeopleStore.Query(QueryExpression <long> .Package(Pids), out PeopleFound)) { long[] Aids = new long[PidsIndex]; int i = 0; foreach (QueryResult <long> pf in PeopleFound) { if (pf.Found) { Aids[i++] = ((Person)pf.Value).AddressID; } } QueryResult <long>[] AddressesFound; if (AddressStore.Query(QueryExpression <long> .Package(Aids), out AddressesFound)) { //** process found Address records here... } } } PidsIndex = 0; } } while (PeopleStoreByName.MoveNext()); }
void ReadAll() { PeopleStoreByName.MoveFirst(); PeopleStoreByName.HintBatchCount = 103; PersonKey pk; int Ctr = 0; do { Ctr++; pk = PeopleStoreByName.CurrentKey; long PersonID = PeopleStoreByName.CurrentValue; if (PeopleStore.Search(PersonID)) { Person p = PeopleStore.CurrentValue; if (AddressStore.Search(p.AddressID)) { Address addr = AddressStore.CurrentValue; } } } while (PeopleStoreByName.MoveNext()); }
//** read all the 5 million records void ReadAll() { 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.Query(QueryExpression <long> .Package(Pids), out People)) { foreach (var p in People) { if (!p.Found) { personMissing = true; Console.WriteLine("Person with ID {0} not found.", p.Key); } } } 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.Query(QueryExpression <long> .Package(d), out People)) { foreach (var p in People) { if (!p.Found) { personMissing = true; Console.WriteLine("Person with ID {0} not found.", p.Key); } } } } if (personMissing) { Console.WriteLine("Failed! Mising person detected."); return; } if (Ctr != PeopleStore.Count) { Console.WriteLine("Failed! Read {0}, expected {1}", Ctr, PeopleStore.Count); } else { Console.WriteLine("Read {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(); }
void ReadAll() { PeopleStoreByName.MoveFirst(); PeopleStoreByName.HintBatchCount = 103; long[] Pids = new long[BatchCount]; int PidsIndex = 0; PersonKey[] pk = new PersonKey[BatchCount]; int Ctr = 0; do { Ctr++; pk[PidsIndex++] = PeopleStoreByName.CurrentKey; if (PidsIndex == BatchCount) { QueryResult <PersonKey>[] PeopleIDs; if (PeopleStoreByName.Query(QueryExpression <PersonKey> .Package(pk), out PeopleIDs)) { for (int i = 0; i < PeopleIDs.Length; i++) { Pids[i] = (long)PeopleIDs[i].Value; } QueryResult <long>[] PeopleFound; if (PeopleStore.Query(QueryExpression <long> .Package(Pids), out PeopleFound)) { long[] Aids = new long[PidsIndex]; int i = 0; foreach (QueryResult <long> pf in PeopleFound) { if (pf.Found) { Aids[i++] = ((Person)pf.Value).AddressID; } } QueryResult <long>[] AddressesFound; if (AddressStore.Query(QueryExpression <long> .Package(Aids), out AddressesFound)) { //** process found Address records here... int ctr2 = 0; foreach (var a in AddressesFound) { ctr2++; if (!a.Found) { Console.WriteLine("Failed to read {0}.", a.Key); } } if (ctr2 != 1000) { Console.WriteLine("Failed to read 1000 records, 'only read {0}.", ctr2); } } } } PidsIndex = 0; } } while (PeopleStoreByName.MoveNext()); if (Ctr != PeopleStore.Count) { Console.WriteLine("Failed! Read {0}, expected {1}", Ctr * 4, PeopleStore.Count * 4); } else { Console.WriteLine("Read {0} items.", Ctr * 4); } }