Example #1
0
        void Populate()
        {
            int ZipCodeCtr = 5000;

            Person[] NewPeople         = new Person[1000];
            int      NewPeopleIndex    = 0;
            bool     oneTimeUpdateRead = true;

            for (int i = 0; i < MaxCount; i++)
            {
                int    pid = GetNextSequence();
                Person p   = new Person()
                {
                    PersonID = pid,
                    Key      = new PersonKey()
                    {
                        FirstName = string.Format("Joe{0}", pid),
                        LastName  = string.Format("Peter{0}", pid)
                    },
                    PhoneNumber = "510-555-9999"
                };
                PeopleStore.Add(p.PersonID, p);
                NewPeople[NewPeopleIndex++] = p;
                //** do inserts on People Store By Name every batch of 1000 records
                //** to minimize disk I/O head jumps, causing more optimal insertion times...
                if (NewPeopleIndex == 1000)
                {
                    foreach (Person np in NewPeople)
                    {
                        PeopleStoreByName.Add(np.Key, np.PersonID);
                    }
                    NewPeopleIndex = 0;
                }
                //** NOTE: SOP supports very large transactions.
                //** In this case we've set it to commit every x00,000 insertions on two tables.
                //** Each one of these operations is a high speed operation and requires fairly reasonable resource footprint
                if (i > 0 && i % TransactionSize == 0)
                {
                    if (NewPeopleIndex > 0)
                    {
                        for (int i2 = 0; i2 < NewPeopleIndex; i2++)
                        {
                            Person np = NewPeople[i2];
                            PeopleStoreByName.Add(np.Key, np.PersonID);
                        }
                        NewPeopleIndex = 0;
                    }
                    ZipCodeCtr++;
                }
            }
            if (NewPeopleIndex > 0)
            {
                for (int i2 = 0; i2 < NewPeopleIndex; i2++)
                {
                    Person np = NewPeople[i2];
                    PeopleStoreByName.Add(np.Key, np.PersonID);
                }
            }
        }
        void Populate()
        {
            int ZipCodeCtr = 5000;

            Person[] PeopleBuffer      = new Person[BatchCount];
            int      PeopleBufferIndex = 0;

            for (int i = 0; i < MaxCount; i++)
            {
                int    pid = (int)PeopleStore.GetNextSequence();
                Person p   = new Person()
                {
                    PersonID = pid,
                    Key      = new PersonKey()
                    {
                        FirstName = string.Format("Joe{0}", pid),
                        LastName  = string.Format("Peter{0}", pid)
                    },
                    PhoneNumber = "510-555-9999"
                };
                PeopleStore.Add(p.PersonID, p);
                PeopleBuffer[PeopleBufferIndex++] = p;

                //** Insert to PeopleStoreByName every batch of BatchCount People
                //** This allows optimal insertion across two tables as low level File pointer jumps are minimized
                if (PeopleBufferIndex == BatchCount)
                {
                    PeopleStore.Flush();
                    foreach (Person p2 in PeopleBuffer)
                    {
                        PeopleStoreByName.Add(p2.Key, p2.PersonID);
                    }
                    PeopleStoreByName.Flush();
                    PeopleBufferIndex = 0;
                }
                if (i % 500 == 0)
                {
                    ZipCodeCtr++;
                }
            }
            if (PeopleBufferIndex > 0)
            {
                PeopleStore.Flush();
                foreach (Person p2 in PeopleBuffer)
                {
                    PeopleStoreByName.Add(p2.Key, p2.PersonID);
                }
                PeopleStoreByName.Flush();
            }
            else
            {
                PeopleStore.Flush();
                PeopleStoreByName.Flush();
            }
        }
Example #3
0
        void Populate()
        {
            int ZipCodeCtr = 5000;

            for (int i = 0; i < MaxCount; i++)
            {
                int     aid  = (int)AddressStore.GetNextSequence();
                Address addr = new Address()
                {
                    AddressID = aid,
                    Key       = new AddressKey()
                    {
                        Street  = string.Format("143{0} LoveLane", aid),
                        City    = "Fremont",
                        Country = "USA",
                        State   = "California",
                        ZipCode = ZipCodeCtr.ToString()
                    }
                };
                int    pid = (int)PeopleStore.GetNextSequence();
                Person p   = new Person()
                {
                    PersonID  = pid,
                    AddressID = addr.AddressID,
                    Key       = new PersonKey()
                    {
                        FirstName = string.Format("Joe{0}", pid),
                        LastName  = string.Format("Peter{0}", pid)
                    },
                    PhoneNumber = "510-555-9999"
                };
                AddressStore.Add(addr.AddressID, addr);
                PeopleStore.Add(p.PersonID, p);
                PeopleStoreByName.Add(p.Key, p.PersonID);
                AddressStoreByAddress.Add(addr.Key, addr.AddressID);
                if (i % 500 == 0)
                {
                    ZipCodeCtr++;
                    AddressStore.Flush();
                    PeopleStore.Flush();
                    PeopleStoreByName.Flush();
                    AddressStoreByAddress.Flush();
                }
            }
            AddressStore.Flush();
            PeopleStore.Flush();
            PeopleStoreByName.Flush();
            AddressStoreByAddress.Flush();
        }
Example #4
0
        void Populate()
        {
            int ZipCodeCtr = 5000;

            CacheRecord[] BatchedRecords = new CacheRecord[BatchCount];
            int           BatchedIndex   = 0;

            for (int i = 0; i < MaxCount; i++)
            {
                int     aid  = (int)AddressStore.GetNextSequence();
                Address addr = new Address()
                {
                    AddressID = aid,
                    Key       = new AddressKey()
                    {
                        Street  = string.Format("143{0} LoveLane", aid),
                        City    = "Fremont",
                        Country = "USA",
                        State   = "California",
                        ZipCode = ZipCodeCtr.ToString()
                    }
                };
                int    pid = (int)PeopleStore.GetNextSequence();
                Person p   = new Person()
                {
                    PersonID  = pid,
                    AddressID = addr.AddressID,
                    Key       = new PersonKey()
                    {
                        FirstName = string.Format("Joe{0}", pid),
                        LastName  = string.Format("Peter{0}", pid)
                    },
                    PhoneNumber = "510-555-9999"
                };
                BatchedRecords[BatchedIndex++] = new CacheRecord()
                {
                    p       = p,
                    pKey    = p.Key,
                    addr    = addr,
                    addrKey = addr.Key
                };
                if (BatchedIndex == BatchCount)
                {
                    for (int i2 = 0; i2 < BatchedIndex; i2++)
                    {
                        AddressStore.Add(BatchedRecords[i2].addr.AddressID,
                                         BatchedRecords[i2].addr);
                    }
                    AddressStore.Flush();
                    for (int i2 = 0; i2 < BatchedIndex; i2++)
                    {
                        PeopleStore.Add(BatchedRecords[i2].p.PersonID,
                                        BatchedRecords[i2].p);
                    }
                    PeopleStore.Flush();
                    for (int i2 = 0; i2 < BatchedIndex; i2++)
                    {
                        PeopleStoreByName.Add(BatchedRecords[i2].p.Key,
                                              BatchedRecords[i2].p.PersonID);
                    }
                    PeopleStoreByName.Flush();
                    for (int i2 = 0; i2 < BatchedIndex; i2++)
                    {
                        AddressStoreByAddress.Add(BatchedRecords[i2].addr.Key,
                                                  BatchedRecords[i2].addr.AddressID);
                    }
                    AddressStoreByAddress.Flush();
                    if (i % 500 == 0)
                    {
                        ZipCodeCtr++;
                    }
                    BatchedIndex = 0;
                }
            }
            if (BatchedIndex > 0)
            {
                for (int i2 = 0; i2 < BatchedIndex; i2++)
                {
                    AddressStore.Add(BatchedRecords[i2].addr.AddressID,
                                     BatchedRecords[i2].addr);
                }
                AddressStore.Flush();
                for (int i2 = 0; i2 < BatchedIndex; i2++)
                {
                    PeopleStore.Add(BatchedRecords[i2].p.PersonID,
                                    BatchedRecords[i2].p);
                }
                PeopleStore.Flush();
                for (int i2 = 0; i2 < BatchedIndex; i2++)
                {
                    PeopleStoreByName.Add(BatchedRecords[i2].p.Key,
                                          BatchedRecords[i2].p.PersonID);
                }
                PeopleStoreByName.Flush();
                for (int i2 = 0; i2 < BatchedIndex; i2++)
                {
                    AddressStoreByAddress.Add(BatchedRecords[i2].addr.Key,
                                              BatchedRecords[i2].addr.AddressID);
                }
                AddressStoreByAddress.Flush();
            }
        }