예제 #1
0
        private void RebalanceRoot(Cursor cursor, TreeDataInTransaction txInfo, Page page)
        {
            if (page.NumberOfEntries == 0)
            {
                return; // nothing to do
            }
            if (!page.IsBranch || page.NumberOfEntries > 1)
            {
                return; // cannot do anything here
            }
            // in this case, we have a root pointer with just one pointer, we can just swap it out

            var node = page.GetNode(0);

            Debug.Assert(node->Flags == (NodeFlags.PageRef));

            _tx.ModifyCursor(txInfo, cursor);
            txInfo.State.LeafPages   = 1;
            txInfo.State.BranchPages = 0;
            txInfo.State.Depth       = 1;
            txInfo.State.PageCount   = 1;

            var rootPage = _tx.ModifyPage(_txInfo.Tree, null, node->PageNumber, cursor);

            rootPage.ItemCount    = 1;
            txInfo.RootPageNumber = rootPage.PageNumber;

            Debug.Assert(rootPage.Dirty);

            cursor.Pop();
            cursor.Push(rootPage);

            _tx.FreePage(page.PageNumber);
        }
예제 #2
0
 public PageSplitter(Transaction tx, SliceComparer cmp, Slice newKey, int len, long pageNumber, Cursor cursor, TreeDataInTransaction txInfo)
 {
     _tx         = tx;
     _cmp        = cmp;
     _newKey     = newKey;
     _len        = len;
     _pageNumber = pageNumber;
     _cursor     = cursor;
     _txInfo     = txInfo;
     _page       = _cursor.Pop();
 }
예제 #3
0
파일: Tree.cs 프로젝트: ppekrol/raven.voron
        private long WriteToOverflowPages(Transaction tx, TreeDataInTransaction txInfo, int overflowSize, out byte *dataPos)
        {
            var numberOfPages     = GetNumberOfOverflowPages(tx, overflowSize);
            var overflowPageStart = tx.AllocatePage(numberOfPages);

            overflowPageStart.Flags        = PageFlags.Overflow;
            overflowPageStart.OverflowSize = overflowSize;
            dataPos = overflowPageStart.Base + Constants.PageHeaderSize;
            txInfo.State.OverflowPages += numberOfPages;
            txInfo.State.PageCount     += numberOfPages;
            return(overflowPageStart.PageNumber);
        }
예제 #4
0
 public TreeRebalancer(Transaction tx, TreeDataInTransaction txInfo, SliceComparer cmp)
 {
     _tx     = tx;
     _txInfo = txInfo;
     _cmp    = cmp;
 }