Beispiel #1
0
 private uint[] GetOffsets()
 {
     uint[] k;
     lock (_lock)
     {
         k = new uint[_offsets.Count()];
         _offsets.Keys().CopyTo(k, 0);
     }
     Array.Sort(k);
     return(k);
 }
Beispiel #2
0
 public void SaveIndex()
 {
     //_log.Debug("Total split time (s) = " + _totalsplits);
     //_log.Debug("Total pages = " + _pageList.Count);
     int[] keys = _cache.Keys();
     Array.Sort(keys);
     // save index to disk
     foreach (var i in keys)
     {
         var p = _cache.GetValue(i);
         if (p.isDirty)
         {
             _index.SavePage(p);
             p.isDirty = false;
         }
     }
     _index.SavePageList(_pageList, _pageListDiskPages);
     _index.BitmapFlush();
 }
Beispiel #3
0
        public void Commit(bool freeMemory)
        {
            if (_isDirty == false)
            {
                return;
            }
            using (new L(this))
            {
                log.Debug("writing " + _filename);

                int[] keys = _cache.Keys();
                Array.Sort(keys);

                foreach (int k in keys)
                {
                    MGRB bmp = null;
                    if (_cache.TryGetValue(k, out bmp) && bmp.isDirty)
                    {
                        bmp.Optimize();
                        SaveBitmap(k, bmp);
                        bmp.isDirty = false;
                    }
                }
                Flush();
                if (freeMemory)
                {
                    if (Global.UseLessMemoryStructures)
                    {
                        _cache = new SafeSortedList <int, MGRB>();
                    }
                    else
                    {
                        _cache = new SafeDictionary <int, MGRB>();
                    }
                    log.Debug("  freeing cache");
                }
                _isDirty = false;
            }
        }