本文整理汇总了C#中Voron.Trees.Page.ClearPrefixInfo方法的典型用法代码示例。如果您正苦于以下问题:C# Page.ClearPrefixInfo方法的具体用法?C# Page.ClearPrefixInfo怎么用?C# Page.ClearPrefixInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Voron.Trees.Page
的用法示例。
在下文中一共展示了Page.ClearPrefixInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultiAddOnNewValue
private void MultiAddOnNewValue(Transaction tx, Slice key, Slice value, ushort? version, int maxNodeSize)
{
MemorySlice valueToInsert;
if(KeysPrefixing)
valueToInsert = new PrefixedSlice(value); // first item is never prefixed
else
valueToInsert = value;
var requiredPageSize = Constants.PageHeaderSize + SizeOf.LeafEntry(-1, valueToInsert, 0) + Constants.NodeOffsetSize;
if (requiredPageSize > maxNodeSize)
{
// no choice, very big value, we might as well just put it in its own tree from the get go...
// otherwise, we would have to put this in overflow page, and that won't save us any space anyway
var tree = Create(tx, KeysPrefixing, TreeFlags.MultiValue);
tree.DirectAdd(value, 0);
tx.AddMultiValueTree(this, key, tree);
DirectAdd(key, sizeof (TreeRootHeader), NodeFlags.MultiValuePageRef);
return;
}
var actualPageSize = (ushort) Math.Min(Utils.NearestPowerOfTwo(requiredPageSize), maxNodeSize);
var ptr = DirectAdd(key, actualPageSize);
var nestedPage = new Page(ptr, "multi tree", actualPageSize)
{
PageNumber = -1L,// hint that this is an inner page
Lower = (ushort) Constants.PageHeaderSize,
Upper = KeysPrefixing ? (ushort)(actualPageSize - Constants.PrefixInfoSectionSize) : actualPageSize,
Flags = KeysPrefixing ? PageFlags.Leaf | PageFlags.KeysPrefixed : PageFlags.Leaf,
};
nestedPage.ClearPrefixInfo();
CheckConcurrency(key, value, version, 0, TreeActionType.Add);
nestedPage.AddDataNode(0, valueToInsert, 0, 0);
}
示例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);
}
}