Ejemplo n.º 1
0
    public Document(UInt64 id): base(id) {} // for lookups

    public Document(string url, IndexRoot indexRoot, SessionBase session)
    {
      this.url = url;
      HashCodeComparer<Word> hashCodeComparer = new HashCodeComparer<Word>();
      m_wordHit = new BTreeMapOidShort<Word, WordHit>(null, session);
      m_wordHit.TransientBatchSize = 10000;
      wordSet = new BTreeSetOidShort<Word>(hashCodeComparer, session, 1500, sizeof(int));
    }
Ejemplo n.º 2
0
        public override IEnumerable <KeyValuePair <long, Tick> > Read()
        {
            BTreeMapOidShort <long, VelocityTick> map = (BTreeMapOidShort <long, VelocityTick>)session.Open(mapId);

            foreach (KeyValuePair <long, VelocityTick> pair in map)
            {
                yield return(new KeyValuePair <long, Tick>(pair.Key, pair.Value.Record));
            }
        }
Ejemplo n.º 3
0
        }                                   // for lookups

        public Document(string url, IndexRoot indexRoot, SessionBase session)
        {
            this.url = url;
            HashCodeComparer <Word> hashCodeComparer = new HashCodeComparer <Word>();

            m_wordHit = new BTreeMapOidShort <Word, WordHit>(null, session);
            m_wordHit.TransientBatchSize = 10000;
            wordSet = new BTreeSetOidShort <Word>(hashCodeComparer, session, 1500, sizeof(int));
        }
Ejemplo n.º 4
0
        public override void Write(int flowID, IEnumerable <KeyValuePair <long, Tick> > flow)
        {
            Placement place = new Placement((ushort)checked (flowID + 10));
            Placement velocityRecordPlace = new Placement((ushort)(flowID + 10), 1000, 1, 10000, ushort.MaxValue, false, false, UInt32.MaxValue, false);

            BTreeMapOidShort <long, VelocityTick> map = new BTreeMapOidShort <long, VelocityTick>(null, session, 1000);

            mapId = map.Persist(place, session);
            map.ValuePlacement     = velocityRecordPlace;
            map.TransientBatchSize = 2000;

            foreach (var kv in flow)
            {
                VelocityTick tick = new VelocityTick(kv.Value);
                map.AddFast(kv.Key, tick);
            }
        }
Ejemplo n.º 5
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     using (SessionNoServer session = new SessionNoServer(systemDir))
     {
         Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
         const UInt32 numberOfPersons              = 10000;
         const ushort nodeMaxSize                  = 5000;
         const ushort comparisonByteArraySize      = sizeof(UInt64); // enough room to hold entire idNumber of a Person
         const bool   comparisonArrayIsCompleteKey = true;
         const bool   addIdCompareIfEqual          = false;
         Person       person;
         session.BeginUpdate();
         session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.None;
         //mySession.SetTraceAllDbActivity();
         BTreeSet <string>                 stringSet      = new BTreeSet <string>(null, session);
         BTreeSetOidShort <string>         stringSetShort = new BTreeSetOidShort <string>(null, session);
         BTreeMap <string, string>         stringMap      = new BTreeMap <string, string>(null, session);
         BTreeMapOidShort <string, string> stringMapShort = new BTreeMapOidShort <string, string>(null, session);
         CompareByField <Person>           compareByField = new CompareByField <Person>("idNumber", session, addIdCompareIfEqual);
         BTreeSet <Person>                 bTree          = new BTreeSet <Person>(compareByField, session, nodeMaxSize, comparisonByteArraySize, comparisonArrayIsCompleteKey);
         session.Persist(bTree); // Persist the root of the BTree so that we have something persisted that can be flushed to disk if memory available becomes low
         for (int i = 0; i < numberOfPersons; i++)
         {
             person = new Person();
             // session.Persist(person);
             bTree.AddFast(person);
         }
         session.Commit();
     }
     using (SessionNoServer session = new SessionNoServer(systemDir))
     {
         session.UseExternalStorageApi = true;
         session.BeginRead();
         BTreeSet <Person> bTree = session.AllObjects <BTreeSet <Person> >().First();
         foreach (Person person in (IEnumerable <Person>)bTree)
         {
             if (person.IdNumber > 196988888791402)
             {
                 Console.WriteLine(person);
                 break;
             }
         }
         session.Commit();
     }
 }
Ejemplo n.º 6
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
     const UInt32 numberOfPersons = 10000;
     const ushort nodeMaxSize = 5000;
     const ushort comparisonByteArraySize = sizeof(UInt64); // enough room to hold entire idNumber of a Person
     const bool comparisonArrayIsCompleteKey = true;
     const bool addIdCompareIfEqual = false;
     Person person;
     session.BeginUpdate();
     session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.None;
     //mySession.SetTraceAllDbActivity();
     BTreeSet<string> stringSet = new BTreeSet<string>(null, session);
     BTreeSetOidShort<string> stringSetShort = new BTreeSetOidShort<string>(null, session);
     BTreeMap<string, string> stringMap = new BTreeMap<string, string>(null, session);
     BTreeMapOidShort<string, string> stringMapShort = new BTreeMapOidShort<string, string>(null, session);
     CompareByField<Person> compareByField = new CompareByField<Person>("idNumber", session, addIdCompareIfEqual);
     BTreeSet<Person> bTree = new BTreeSet<Person>(compareByField, session, nodeMaxSize, comparisonByteArraySize, comparisonArrayIsCompleteKey);
     session.Persist(bTree); // Persist the root of the BTree so that we have something persisted that can be flushed to disk if memory available becomes low
     for (int i = 0; i < numberOfPersons; i++)
     {
       person = new Person();
       // session.Persist(person);
       bTree.AddFast(person);
     }
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.UseExternalStorageApi = true;
     session.BeginRead();
     BTreeSet<Person> bTree = session.AllObjects<BTreeSet<Person>>().First();
     foreach (Person person in (IEnumerable<Person>)bTree)
     {
       if (person.IdNumber > 196988888791402)
       {
         Console.WriteLine(person);
         break;
       }
     }
     session.Commit();
   }
 }
Ejemplo n.º 7
0
        public void aCreateDefaultCompareOidShortIntKeyIntValue(int number)
        {
            Oid id;

            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                Placement place = new Placement((UInt32)number, 1, 1, UInt16.MaxValue, UInt16.MaxValue);
                session.Compact();
                session.BeginUpdate();
                BTreeMapOidShort <int, int> bTree = new BTreeMapOidShort <int, int>(null, session);
                bTree.Persist(place, session);
                id = bTree.Oid;
                for (int i = 0; i < number; i++)
                {
                    bTree.Add(i, i + 1);
                }
                bTree.Clear();
                for (int i = 0; i < number; i++)
                {
                    bTree.Add(i, i + 1);
                }
                session.Commit();
            }
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginRead();
                BTreeMapOidShort <int, int> bTree = (BTreeMapOidShort <int, int>)session.Open(id);
                int count = 0;
                int prior = 0;
                foreach (KeyValuePair <int, int> pair in bTree)
                {
                    count++;
                    Assert.True(pair.Key == prior++);
                    Assert.True(pair.Key == pair.Value - 1);
                }
                Assert.True(number == count);
                session.Commit();
            }
        }
Ejemplo n.º 8
0
 public void aCreateDefaultCompareOidShortIntKeyIntValue(int number)
 {
   Oid id;
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     Placement place = new Placement((UInt32)number, 1, 1, UInt16.MaxValue, UInt16.MaxValue);
     session.Compact();
     session.BeginUpdate();
     BTreeMapOidShort<int, int> bTree = new BTreeMapOidShort<int, int>(null, session);
     bTree.Persist(place, session);
     id = bTree.Oid;
     for (int i = 0; i < number; i++)
     {
       bTree.Add(i, i + 1);
     }
     bTree.Clear();
     for (int i = 0; i < number; i++)
     {
       bTree.Add(i, i + 1);
     }
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginRead();
     BTreeMapOidShort<int, int> bTree = (BTreeMapOidShort<int, int>)session.Open(id);
     int count = 0;
     int prior = 0;
     foreach (KeyValuePair<int, int> pair in bTree)
     {
       count++;
       Assert.True(pair.Key == prior++);
       Assert.True(pair.Key == pair.Value - 1);
     }
     Assert.True(number == count);
     session.Commit();
   }
 }