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


C# Page.SetNodeKey方法代码示例

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

示例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;
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:30,代码来源:TreeIterator.cs


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