private Page <T> LoadPage(T key, out PageInfo pageinfo) { int pagenum = -1; // find page in list of pages bool found = false; int pos = 0; if (key != null) { pos = FindPageOrLowerPosition(key, ref found); } pageinfo = _pageList.GetValue(pos); pagenum = pageinfo.PageNumber; Page <T> page; if (_cache.TryGetValue(pagenum, out page) == false) { //load page from disk page = _index.LoadPageFromPageNumber(pagenum); _cache.Add(pagenum, page); } return(page); }
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; } }
public bool Get(int index) { lock (_lock) { if (_state == TYPE.Indexes) { bool b = false; var f = _offsets.TryGetValue((uint)index, out b); if (f) { return(b); } else { return(false); } } CheckBitArray(); Resize(index); return(internalGet(index)); } }