本文整理汇总了C#中Voron.Trees.Page.NodePositionFor方法的典型用法代码示例。如果您正苦于以下问题:C# Page.NodePositionFor方法的具体用法?C# Page.NodePositionFor怎么用?C# Page.NodePositionFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Voron.Trees.Page
的用法示例。
在下文中一共展示了Page.NodePositionFor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertNewKey
private byte* InsertNewKey(Page p)
{
int pos = p.NodePositionFor(_newKey);
var newKeyToInsert = p.PrepareKeyToInsert(_newKey, pos);
if (p.HasSpaceFor(_tx, p.GetRequiredSpace(newKeyToInsert, _len)) == false)
{
_cursor.Push(p);
var pageSplitter = new PageSplitter(_tx, _tree, _newKey, _len, _pageNumber, _nodeType, _nodeVersion, _cursor, _treeState);
return pageSplitter.Execute();
}
byte* dataPos = AddNodeToPage(p, pos, newKeyToInsert);
_cursor.Push(p);
return dataPos;
}
示例2: TryUseRecentTransactionPage
private bool TryUseRecentTransactionPage(Transaction tx, Slice key, out Lazy<Cursor> cursor, out Page page)
{
page = null;
cursor = null;
var recentPages = tx.GetRecentlyFoundPages(this);
if (recentPages == null)
return false;
var foundPage = recentPages.Find(key);
if (foundPage == null)
return false;
var lastFoundPageNumber = foundPage.Number;
page = tx.GetReadOnlyPage(lastFoundPageNumber);
if (page.IsLeaf == false)
throw new DataException("Index points to a non leaf page");
page.NodePositionFor(key, _cmp); // will set the LastSearchPosition
var cursorPath = foundPage.CursorPath;
var pageCopy = page;
cursor = new Lazy<Cursor>(() =>
{
var c = new Cursor();
foreach (var p in cursorPath)
{
if (p == lastFoundPageNumber)
c.Push(pageCopy);
else
{
var cursorPage = tx.GetReadOnlyPage(p);
if (key.Options == SliceOptions.BeforeAllKeys)
{
cursorPage.LastSearchPosition = 0;
}
else if (key.Options == SliceOptions.AfterAllKeys)
{
cursorPage.LastSearchPosition = (ushort)(cursorPage.NumberOfEntries - 1);
}
else if (cursorPage.Search(key, _cmp) != null)
{
if (cursorPage.LastMatch != 0)
{
cursorPage.LastSearchPosition--;
}
}
c.Push(cursorPage);
}
}
return c;
});
return true;
}
示例3: InsertNewKey
private byte* InsertNewKey(Page p)
{
int pos = p.NodePositionFor(_newKey);
byte* dataPos = AddNodeToPage(p, pos);
_cursor.Push(p);
return dataPos;
}