Exemplo n.º 1
0
        void UpdateReadAll()
        {
            // update some people's blobs...
            for (int i = 100; i < 5000; i++)
            {
                var p = new Person()
                {
                    FirstName = string.Format("Joe{0}", i),
                    LastName  = string.Format("Peter{0}", i)
                };
                var blob = new PersonBlob
                {
                    Blob = new byte[PersonBlob.BlobAvgSize + 100]
                };
                blob.Blob[2]   = (byte)i;
                PeopleStore[p] = blob;
            }
            PeopleStore.Transaction.Commit();

            // now, read them all..
            PeopleStore.MoveFirst();
            PeopleStore.HintBatchCount = 103;
            var pk  = new PersonBlob[BatchCount];
            int Ctr = 0;

            do
            {
                Ctr++;
                var blob = PeopleStore.CurrentValue;
            } while (PeopleStore.MoveNext());
            Console.WriteLine("Processed {0} records.", Ctr);
        }
Exemplo n.º 2
0
        void Populate(ISortedDictionary <string, object> Store)
        {
            for (int i = 0; i < MaxCount; i++)
            {
                int    pid   = (int)Store.GetNextSequence();
                string key   = string.Empty;
                object value = null;
                switch (i % 4)
                {
                case 0:
                    key   = string.Format("PersonBlob{0}", pid);
                    value = new PersonBlob
                    {
                        Blob = new byte[PersonBlob.BlobAvgSize]
                    };
                    break;

                case 1:
                    key   = string.Format("Person{0}", pid);
                    value = new Person
                    {
                        FirstName = string.Format("Joe {0}", pid),
                        LastName  = string.Format("Curly {0}", pid)
                    };
                    break;

                case 2:
                    key   = string.Format("Address{0}", pid);
                    value = new Address
                    {
                        Street  = string.Format("123 Love Lane {0}", pid),
                        City    = "Fremont",
                        State   = "California",
                        Country = "U.S.A.",
                        ZipCode = 94599
                    };
                    break;

                case 3:
                    key   = string.Format("Dept{0}", pid);
                    value = new Department
                    {
                        Id   = pid,
                        Name = string.Format("Dept {0}", pid)
                    };
                    break;
                }
                Store.Add(key, value);
                if (i % 2000 == 0)
                {
                    Store.Flush();
                }
            }
        }
Exemplo n.º 3
0
        void ReadAll()
        {
            // nullify some people's blobs...
            for (int i = 100; i < 5000; i++)
            {
                var p = new Person()
                {
                    FirstName = string.Format("Joe{0}", i),
                    LastName  = string.Format("Peter{0}", i)
                };
                PeopleStore[p] = null;
            }
            Server.CycleTransaction();
            // update nullified people's blobs...
            for (int i = 100; i < 5000; i++)
            {
                var p = new Person()
                {
                    FirstName = string.Format("Joe{0}", i),
                    LastName  = string.Format("Peter{0}", i)
                };
                var blob = new PersonBlob
                {
                    Blob = new byte[PersonBlob.BlobAvgSize + 7000]
                };
                blob.Blob[2]   = (byte)i;
                PeopleStore[p] = blob;
            }
            PeopleStore.Transaction.Commit();

            var personBatch = new Person[1000];
            int index       = 0;
            int Ctr         = 0;

            for (int i = 0; i < MaxCount; i++)
            {
                Ctr++;
                var p = new Person()
                {
                    FirstName = string.Format("Joe{0}", i),
                    LastName  = string.Format("Peter{0}", i)
                };
                personBatch[index++] = p;
                if (index >= personBatch.Length)
                {
                    QueryResult <Person>[] r;
                    PeopleStore.Query(QueryExpression <Person> .Package(personBatch), out r);
                    index = 0;
                }
            }
            Console.WriteLine("Processed {0} records.", Ctr);
        }
Exemplo n.º 4
0
        void ReadAll()
        {
            PeopleStore.MoveFirst();
            PeopleStore.HintBatchCount = 103;
            var pk  = new PersonBlob[BatchCount];
            int Ctr = 0;

            do
            {
                Ctr++;
                var blob = PeopleStore.CurrentValue;
            } while (PeopleStore.MoveNext());
            Console.WriteLine("Processed {0} records.", Ctr);
        }