Ejemplo n.º 1
0
        public MGIndex(string path, string filename, byte keysize, bool allowdups)
        {
            if (Global.UseLessMemoryStructures)
            {
                _cache = new SafeSortedList <int, Page <T> >();
            }
            else
            {
                _cache = new SafeDictionary <int, Page <T> >();
            }

            _AllowDuplicates = allowdups;
            if (path.EndsWith(Path.DirectorySeparatorChar.ToString()) == false)
            {
                path += Path.DirectorySeparatorChar;
            }

            _index = new IndexFile <T>(path + filename, keysize);
            // load page list
            _index.GetPageList(_pageListDiskPages, _pageList, out _LastIndexedRecordNumber);
            if (_pageList.Count() == 0)
            {
                Page <T> page = new Page <T>();
                page.FirstKey = (T)RDBDataType <T> .GetEmpty();

                page.DiskPageNumber = _index.GetNewPageNumber();
                page.isDirty        = true;
                _pageList.Add(page.FirstKey, new PageInfo(page.DiskPageNumber, 0, 0));
                _cache.Add(page.DiskPageNumber, page);
            }
        }
Ejemplo n.º 2
0
        //private int _maxPageItems = 0;

        public MGIndex(string path, string filename, byte keysize, /*ushort maxcount,*/ bool allowdups)
        {
            _AllowDuplicates = allowdups;
            _index           = new IndexFile <T>(path + Path.DirectorySeparatorChar + filename, keysize);//, maxcount);
            //_maxPageItems = maxcount;
            // load page list
            _index.GetPageList(_pageListDiskPages, _pageList, out _LastIndexedRecordNumber);
            if (_pageList.Count == 0)
            {
                Page <T> page = new Page <T>();
                page.FirstKey = (T)RDBDataType <T> .GetEmpty();

                page.DiskPageNumber = _index.GetNewPageNumber();
                page.isDirty        = true;
                _pageList.Add(page.FirstKey, new PageInfo(page.DiskPageNumber, 0, 0));
                _cache.Add(page.DiskPageNumber, page);
            }
        }