本文整理汇总了C#中IPage.SetData方法的典型用法代码示例。如果您正苦于以下问题:C# IPage.SetData方法的具体用法?C# IPage.SetData怎么用?C# IPage.SetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPage
的用法示例。
在下文中一共展示了IPage.SetData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InternalNode
/// <summary>
/// Creates a new node backed by the specified persistent storage page with a single
/// key and left and right pointers.
/// </summary>
/// <param name="page">The page used to back the node. Must be writeable.</param>
/// <param name="splitKey">The key that separates left and right child pointers</param>
/// <param name="leftPageId">The left child node pointer</param>
/// <param name="rightPageId">The right child node pointer</param>
/// <param name="treeConfiguration">The tree configuration</param>
/// <exception cref="InvalidOperationException">Raised if <paramref name="page"/> is not a writeable page</exception>
public InternalNode(IPage page, byte[] splitKey, ulong leftPageId, ulong rightPageId,
BPlusTreeConfiguration treeConfiguration)
{
_config = treeConfiguration;
AssertWriteable(page);
_page = page;
_page.SetData(splitKey, 0, KeyOffset(0), _config.KeySize);
_page.SetData(BitConverter.GetBytes(leftPageId), 0, PointerOffset(0), 8);
_page.SetData(BitConverter.GetBytes(rightPageId), 0, PointerOffset(1), 8);
KeyCount = 1;
#if DEBUG_BTREE
_config.BTreeDebug("+Internal {0}", _page.Id);
#endif
}
示例2: Split
/// <summary>
/// Splits this node into two internal nodes, creating a new node for the right-hand (upper) half of the keys
/// </summary>
/// <param name="txnId"></param>
/// <param name="rightNodePage">The new page reserved to receive the newly created internal node</param>
/// <param name="splitKey">Receives the value of the key used for the split</param>
/// <returns>The new right-hand node</returns>
public IInternalNode Split(ulong txnId, IPage rightNodePage, out byte[] splitKey)
{
#if DEBUG_BTREE
_config.BTreeDebug("InternalNode.Split. Id={0}. Structure Before: {1}", PageId, Dump());
#endif
EnsureWriteable(txnId);
var splitIndex = _config.InternalSplitIndex;
splitKey = GetKey(splitIndex);
rightNodePage.SetData(_page.Data, KeyOffset(splitIndex + 1),
KeyOffset(0),
(KeyCount - (splitIndex + 1))*_config.KeySize);
var pointerCopyStart = PointerOffset(splitIndex + 1);
var pointerCopyLength = (KeyCount - splitIndex)*8;
rightNodePage.SetData(_page.Data, pointerCopyStart,
PointerOffset(0),
pointerCopyLength);
var rightNodeKeyCount = KeyCount - (splitIndex + 1);
rightNodePage.SetData(BitConverter.GetBytes(~rightNodeKeyCount), 0, 0, 4);
var rightNode = new InternalNode(rightNodePage, rightNodeKeyCount, _config);
KeyCount = splitIndex;
#if DEBUG_BTREE
_config.BTreeDebug("InternalNode.Split. Structure After: Id={0} {1}\nRight Node After: Id={2} {3}",
PageId, Dump(), rightNode.PageId, rightNode.Dump());
#endif
return rightNode;
}
示例3: Split
public ILeafNode Split(ulong txnId, IPage rightNodePage, out byte[] splitKey)
{
EnsureWriteable(txnId);
Next = rightNodePage.Id;
splitKey = new byte[_config.KeySize];
int numToMove = KeyCount - _config.LeafSplitIndex;
Array.Copy(_page.Data, KeyOffset(_config.LeafSplitIndex), splitKey, 0, _config.KeySize);
#if DEBUG_BTREE
_config.BTreeDebug("LeafNode.Split. SplitKey={0}. NumToMove={1}. Structure Before: {2}", splitKey.Dump(), numToMove, Dump());
_config.BTreeDebug("[email protected]{0}. Keys before: {1}", PageId, DumpKeys());
#endif
rightNodePage.SetData(_page.Data, KeyOffset(_config.LeafSplitIndex),
KeyOffset(0), numToMove*_config.KeySize);
if (_config.ValueSize > 0)
{
rightNodePage.SetData(_page.Data, ValueOffset(_config.LeafSplitIndex),
ValueOffset(0), numToMove*_config.ValueSize);
}
var rightNodeKeyCount = numToMove;
rightNodePage.SetData(BitConverter.GetBytes(rightNodeKeyCount), 0, 0, 4);
var rightNode = new LeafNode(rightNodePage, rightNodeKeyCount, _config);
KeyCount = _config.LeafSplitIndex;
#if DEBUG_BTREE
_config.BTreeDebug("LeafNode.Split. Structure After : {0}. Right Node After: {1}",
Dump(), rightNode.Dump());
_config.BTreeDebug("[email protected]{0}. Keys after: {1}", PageId, DumpKeys());
#endif
return rightNode;
}