本文整理汇总了C#中Voron.Trees.Page.UseMoreSizeThan方法的典型用法代码示例。如果您正苦于以下问题:C# Page.UseMoreSizeThan方法的具体用法?C# Page.UseMoreSizeThan怎么用?C# Page.UseMoreSizeThan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Voron.Trees.Page
的用法示例。
在下文中一共展示了Page.UseMoreSizeThan方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public Page Execute(Page page)
{
_tree.ClearRecentFoundPages();
if (_cursor.PageCount <= 1) // the root page
{
RebalanceRoot(page);
return null;
}
var parentPage = _tx.ModifyPage(_cursor.ParentPage.PageNumber, _tree, _cursor.ParentPage);
_cursor.Update(_cursor.Pages.First.Next, parentPage);
if (page.NumberOfEntries == 0) // empty page, just delete it and fixup parent
{
// need to change the implicit left page
if (parentPage.LastSearchPosition == 0 && parentPage.NumberOfEntries > 2)
{
var newImplicit = parentPage.GetNode(1)->PageNumber;
parentPage.RemoveNode(0);
parentPage.ChangeImplicitRefPageNode(newImplicit);
}
else // will be set to rights by the next rebalance call
{
parentPage.RemoveNode(parentPage.LastSearchPositionOrLastEntry);
}
_tx.FreePage(page.PageNumber);
_cursor.Pop();
return parentPage;
}
if (page.IsBranch && page.NumberOfEntries == 1)
{
RemoveBranchWithOneEntry(page, parentPage);
_cursor.Pop();
return parentPage;
}
var minKeys = page.IsBranch ? 2 : 1;
if ((page.UseMoreSizeThan(_tx.DataPager.PageMinSpace)) &&
page.NumberOfEntries >= minKeys)
return null; // above space/keys thresholds
Debug.Assert(parentPage.NumberOfEntries >= 2); // if we have less than 2 entries in the parent, the tree is invalid
var sibling = SetupMoveOrMerge(page, parentPage);
Debug.Assert(sibling.PageNumber != page.PageNumber);
if (page.Flags != sibling.Flags)
return null;
minKeys = sibling.IsBranch ? 2 : 1; // branch must have at least 2 keys
if (sibling.UseMoreSizeThan(_tx.DataPager.PageMinSpace) &&
sibling.NumberOfEntries > minKeys)
{
_cursor.Pop();
// neighbor is over the min size and has enough key, can move just one key to the current page
if (page.IsBranch)
MoveBranchNode(parentPage, sibling, page);
else
MoveLeafNode(parentPage, sibling, page);
return parentPage;
}
if (page.LastSearchPosition == 0) // this is the right page, merge left
{
if (TryMergePages(parentPage, sibling, page) == false)
return null;
}
else // this is the left page, merge right
{
if (TryMergePages(parentPage, page, sibling) == false)
return null;
}
_cursor.Pop();
return parentPage;
}