本文整理汇总了C#中Voron.Impl.Transaction.GetRecentlyFoundPages方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.GetRecentlyFoundPages方法的具体用法?C# Transaction.GetRecentlyFoundPages怎么用?C# Transaction.GetRecentlyFoundPages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Voron.Impl.Transaction
的用法示例。
在下文中一共展示了Transaction.GetRecentlyFoundPages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}