本文整理汇总了C#中Voron.Trees.Page.SetNodeKey方法的典型用法代码示例。如果您正苦于以下问题:C# Page.SetNodeKey方法的具体用法?C# Page.SetNodeKey怎么用?C# Page.SetNodeKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Voron.Trees.Page
的用法示例。
在下文中一共展示了Page.SetNodeKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Seek
public bool Seek(Slice key)
{
Lazy<Cursor> lazy;
NodeHeader* node;
_currentPage = _tree.FindPageFor(key, out node, out lazy);
_cursor = lazy.Value;
_cursor.Pop();
if (node != null)
{
_currentPage.SetNodeKey(node, ref _currentInternalKey);
_currentKey = _currentInternalKey.ToSlice();
return this.ValidateCurrentKey(Current, _currentPage);
}
// The key is not found in the db, but we are Seek()ing for equals or starts with.
// We know that the exact value isn't there, but it is possible that the next page has values
// that is actually greater than the key, so we need to check it as well.
_currentPage.LastSearchPosition = _currentPage.NumberOfEntries; // force next MoveNext to move to the next _page_.
return MoveNext();
}
示例2: ExpandMultiTreeNestedPageSize
private void ExpandMultiTreeNestedPageSize(Transaction tx, Slice key, Slice value, byte* nestedPagePtr, ushort newSize, int currentSize)
{
Debug.Assert(newSize > currentSize);
TemporaryPage tmp;
using (tx.Environment.GetTemporaryPage(tx, out tmp))
{
var tempPagePointer = tmp.TempPagePointer;
NativeMethods.memcpy(tempPagePointer, nestedPagePtr, currentSize);
Delete(key); // release our current page
Page nestedPage = new Page(tempPagePointer, "multi tree", (ushort)currentSize);
var ptr = DirectAdd(key, newSize);
var newNestedPage = new Page(ptr, "multi tree", newSize)
{
Lower = (ushort)Constants.PageHeaderSize,
Upper = KeysPrefixing ? (ushort) (newSize - Constants.PrefixInfoSectionSize) : newSize,
Flags = KeysPrefixing ? PageFlags.Leaf | PageFlags.KeysPrefixed : PageFlags.Leaf,
PageNumber = -1L // mark as invalid page number
};
newNestedPage.ClearPrefixInfo();
MemorySlice nodeKey = nestedPage.CreateNewEmptyKey();
for (int i = 0; i < nestedPage.NumberOfEntries; i++)
{
var nodeHeader = nestedPage.GetNode(i);
nestedPage.SetNodeKey(nodeHeader, ref nodeKey);
nodeKey = newNestedPage.PrepareKeyToInsert(nodeKey, i);
newNestedPage.AddDataNode(i, nodeKey, 0,
(ushort)(nodeHeader->Version - 1)); // we dec by one because AdddataNode will inc by one, and we don't want to change those values
}
newNestedPage.Search(value);
newNestedPage.AddDataNode(newNestedPage.LastSearchPosition, newNestedPage.PrepareKeyToInsert(value, newNestedPage.LastSearchPosition), 0, 0);
}
}
示例3: MovePrev
public bool MovePrev()
{
while (true)
{
_currentPage.LastSearchPosition--;
if (_currentPage.LastSearchPosition >= 0)
{
// run out of entries, need to select the next page...
while (_currentPage.IsBranch)
{
_cursor.Push(_currentPage);
var node = _currentPage.GetNode(_currentPage.LastSearchPosition);
_currentPage = _tx.GetReadOnlyPage(node->PageNumber);
_currentPage.LastSearchPosition = _currentPage.NumberOfEntries - 1;
}
var current = _currentPage.GetNode(_currentPage.LastSearchPosition);
if (this.ValidateCurrentKey(current, _currentPage) == false)
return false;
_currentPage.SetNodeKey(current, ref _currentInternalKey);
_currentKey = _currentInternalKey.ToSlice();
return true;// there is another entry in this page
}
if (_cursor.PageCount == 0)
break;
_currentPage = _cursor.Pop();
}
_currentPage = null;
return false;
}