Ejemplo n.º 1
0
 public override UInt64 Persist(Placement place, SessionBase session, bool persistRefs = true, bool disableFlush = false, Queue <IOptimizedPersistable> toPersist = null)
 {
     base.Persist(place, session, false, disableFlush, toPersist);
     priorVerifiedEmailSet.Persist(place, session, true, disableFlush, toPersist);
     licenseRequestSet.Persist(place, session, true, disableFlush, toPersist);
     licenseSet.Persist(place, session, true, disableFlush, toPersist);
     licenseUnpaidSet.Persist(place, session, true, disableFlush, toPersist);
     licenseUnpaidRequestSet.Persist(place, session, true, disableFlush, toPersist);
     licensePaymentSet.Persist(place, session, true, disableFlush, toPersist);
     licensePaymentSet.Persist(place, session, true, disableFlush, toPersist);
     return(Id);
 }
Ejemplo n.º 2
0
        public void hashCodeComparerStringTest()
        {
            Oid id;

            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                Placement place = new Placement(223, 1, 1, UInt16.MaxValue, UInt16.MaxValue);
                session.Compact();
                session.BeginUpdate();
                HashCodeComparer <string> hashCodeComparer = new HashCodeComparer <string>();
                BTreeSet <string>         bTree            = new BTreeSet <string>(hashCodeComparer, session);
                bTree.Persist(place, session);
                id = bTree.Oid;
                for (int i = 0; i < 100000; i++)
                {
                    bTree.Add(i.ToString());
                }
                session.Commit();
            }
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginRead();
                BTreeSet <string> bTree = (BTreeSet <string>)session.Open(id);
                int count = 0;
                foreach (string str in bTree)
                {
                    count++;
                }
                Assert.True(100000 == count);
                session.Commit();
            }
        }
Ejemplo n.º 3
0
 public void hashCodeComparerStringTest()
 {
   Oid id;
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     Placement place = new Placement(223, 1, 1, UInt16.MaxValue, UInt16.MaxValue);
     session.Compact();
     session.BeginUpdate();
     HashCodeComparer<string> hashCodeComparer = new HashCodeComparer<string>();
     BTreeSet<string> bTree = new BTreeSet<string>(hashCodeComparer, session);
     bTree.Persist(place, session);
     id = bTree.Oid;
     for (int i = 0; i < 100000; i++)
     {
       bTree.Add(i.ToString());
     }
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginRead();
     BTreeSet<string> bTree= (BTreeSet<string>)session.Open(id);
     int count = 0;
     foreach (string str in bTree)
     {
       count++;
     }
     Assert.True(100000 == count);
     session.Commit();
   }
 }
Ejemplo n.º 4
0
 public void CreateTicksCompareFields(int numberOfTicks, int nodeSize)
 {
     using (SessionNoServer session = new SessionNoServer(systemDir, 2000, false))
     {
         //session.SetTraceAllDbActivity();
         session.BeginUpdate();
         CompareByField <Tick> compareByField = new CompareByField <Tick>("<Bid>k__BackingField", session, true);
         //compareByField.AddFieldToCompare("<Timestamp>k__BackingField");
         BTreeSet <Tick> bTree      = new BTreeSet <Tick>(compareByField, session, (UInt16)nodeSize, sizeof(double) + sizeof(UInt64), true);
         Placement       place      = new Placement((UInt32)numberOfTicks, 1, 1, UInt16.MaxValue, UInt16.MaxValue);
         Placement       ticksPlace = new Placement((UInt32)numberOfTicks, 10000, 1, UInt16.MaxValue, UInt16.MaxValue);
         bTree.Persist(place, session);
         int i          = 0;
         int dublicates = 0;
         foreach (var record in Tick.GenerateRandom((ulong)numberOfTicks))
         {
             session.Persist(record, ticksPlace);
             if (bTree.Add(record))
             {
                 i++;
             }
             else
             {
                 dublicates++;
             }
         }
         session.Commit();
         Console.WriteLine("Done creating and sorting with BTreeSet<Tick> " + i + " Tick objects by Bid value. Number of dublicates (not added to BTreeSet): " + dublicates);
     }
 }
Ejemplo n.º 5
0
        public void Bug2Test()
        {
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                const ushort nodeMaxSize                  = 5000;
                const ushort comparisonByteArraySize      = sizeof(Int32); // enough room to hold entire idNumber of a Person
                const bool   comparisonArrayIsCompleteKey = true;
                const bool   addIdCompareIfEqual          = false;
                session.BeginUpdate();
                //mySession.SetTraceAllDbActivity();
                CompareByField <Entity> compareByField = new CompareByField <Entity>("idNumber", session, addIdCompareIfEqual);
                BTreeSet <Entity>       bTree          = new BTreeSet <Entity>(compareByField, session, nodeMaxSize, comparisonByteArraySize, comparisonArrayIsCompleteKey);
                Placement place = new Placement(40);
                bTree.Persist(place, session);
                for (int i = 0; i < 5; i++)
                {
                    var x = new Entity();
                    x.idNumber   = 250000;
                    x.UserID     = 100116;
                    x.FirstName  = "Bill";
                    x.LastName   = "Martin";
                    x.MiddleName = "Bob";

                    if (!bTree.Contains(x))
                    {
                        x.Persist(place, session);
                        bTree.Add(x);
                    }
                }
                Assert.IsTrue(bTree.Count == 1);
                session.Commit();
            }
        }
Ejemplo n.º 6
0
        public void CreateCompareFields(int numberOfLoops, int comparisonByteArraySize)
        {
            GCLatencyMode gcLatencyMode = GCSettings.LatencyMode;

            Person.s_randGen = new Random(5);
            try
            {
                using (SessionNoServer session = new SessionNoServer(systemDir))
                {
                    //session.ClientCache.MinimumAvailableMegaBytes = 1100;
                    //session.SetTraceAllDbActivity();
                    Man   aMan;
                    Woman aWoman;
                    session.BeginUpdate();
                    CompareByField <Person> compareByField = new CompareByField <Person>("m_firstName", session, false);
                    compareByField.AddFieldToCompare("m_lastName");
                    compareByField.AddFieldToCompare("m_age");
                    BTreeSet <Person> bTree = new BTreeSet <Person>(compareByField, session, 2000, (ushort)comparisonByteArraySize);
                    Placement         place = new Placement((UInt32)numberOfLoops);
                    bTree.Persist(place, session);
                    for (int i = 0; i < numberOfLoops; i++)
                    {
                        aMan   = new Man();
                        aWoman = new Woman();
                        bTree.AddFast(aMan);
                        bTree.AddFast(aWoman);
                        if (i % 5000 == 0)
                        {
                            bTree.FlushTransients();
                        }
                    }
                    session.Commit();
                }
            }
            finally
            {
                GCSettings.LatencyMode = gcLatencyMode;
            }
        }
Ejemplo n.º 7
0
 public void CreateTicksCompareFields(int numberOfTicks, int nodeSize)
 {
   using (SessionNoServer session = new SessionNoServer(systemDir, 2000, false))
   {
     //session.SetTraceAllDbActivity();
     session.BeginUpdate();
     CompareByField<Tick> compareByField = new CompareByField<Tick>("<Bid>k__BackingField", session, true);
     //compareByField.AddFieldToCompare("<Timestamp>k__BackingField");
     BTreeSet<Tick> bTree = new BTreeSet<Tick>(compareByField, session, (UInt16) nodeSize, sizeof(double) + sizeof(UInt64), true);
     Placement place = new Placement((UInt32)numberOfTicks, 1, 1, UInt16.MaxValue, UInt16.MaxValue);
     Placement ticksPlace = new Placement((UInt32)numberOfTicks, 10000, 1, UInt16.MaxValue, UInt16.MaxValue);
     bTree.Persist(place, session);
     int i = 0;
     int dublicates = 0;
     foreach (var record in Tick.GenerateRandom((ulong) numberOfTicks))
     {
       session.Persist(record, ticksPlace);
       if (bTree.Add(record))
         i++;
       else
         dublicates++;
     }
     session.Commit();
     Console.WriteLine("Done creating and sorting with BTreeSet<Tick> " + i + " Tick objects by Bid value. Number of dublicates (not added to BTreeSet): " + dublicates);
   }
 }
Ejemplo n.º 8
0
 public void CreateCompareFields(int numberOfLoops, int comparisonByteArraySize)
 {
   GCLatencyMode gcLatencyMode = GCSettings.LatencyMode; 
   Person.s_randGen = new Random(5);
   try
   {
     using (SessionNoServer session = new SessionNoServer(systemDir))
     {
       //session.ClientCache.MinimumAvailableMegaBytes = 1100;
       //session.SetTraceAllDbActivity();
       Man aMan;
       Woman aWoman;
       session.BeginUpdate();
       CompareByField<Person> compareByField = new CompareByField<Person>("m_firstName", session, false);
       compareByField.AddFieldToCompare("m_lastName");
       compareByField.AddFieldToCompare("m_age");
       BTreeSet<Person> bTree = new BTreeSet<Person>(compareByField, session, 2000, (ushort)comparisonByteArraySize);
       Placement place = new Placement((UInt32)numberOfLoops);
       bTree.Persist(place, session);
       for (int i = 0; i < numberOfLoops; i++)
       {
         aMan = new Man();
         aWoman = new Woman();
         bTree.AddFast(aMan);
         bTree.AddFast(aWoman);
         if (i % 5000 == 0)
           bTree.FlushTransients();    
       }
       session.Commit();
     }
   }
   finally
   {
     GCSettings.LatencyMode = gcLatencyMode;
   }
 }