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); }
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(); }
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); }
public TreeRebalancer(Transaction tx, TreeDataInTransaction txInfo, SliceComparer cmp) { _tx = tx; _txInfo = txInfo; _cmp = cmp; }