当前位置: 首页>>代码示例>>C#>>正文


C# Page.ClearPrefixInfo方法代码示例

本文整理汇总了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);
        }
开发者ID:jesuslpm,项目名称:ravendb,代码行数:41,代码来源:Tree.MultiTree.cs

示例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);
            }
        }
开发者ID:jesuslpm,项目名称:ravendb,代码行数:37,代码来源:Tree.MultiTree.cs


注:本文中的Voron.Trees.Page.ClearPrefixInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。