Ejemplo n.º 1
0
        private IBPlusTreeNode <TKey> PageToNode(IPage page)
        {
            var node = page.BackingObject as IBPlusTreeNode <TKey>;

            if (node != null)
            {
                return(node);
            }

            var           header = (BPlusTreeNodePageHeader)PageFormatter.GetPageHeader(page);
            List <DbItem> items  = PageFormatter.ReadFixedSizeItems(page);

            var result = new BPlusTreeNode <TKey>(page.Index, items.Count)
            {
                IsLeaf            = header.IsLeaf,
                ParentNodeIndex   = header.ParentPageIndex,
                PreviousNodeIndex = header.PreviousPageIndex,
                NextNodeIndex     = header.NextPageIndex
            };

            int cnt = items.Count;

            for (int i = 0; i < cnt; i++)
            {
                result.Entries.Add(IndexEntryFromBytes(items[i].RawData));
            }

            page.BackingObject = result;

            if (_nodeEntrySizeRange != header.SizeRange)
            {
                throw new DataTankerException("Mismatch key size"); // TODO: specify possible size range
            }
            return(result);
        }