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


C# Transaction.FreePage方法代码示例

本文整理汇总了C#中Voron.Impl.Transaction.FreePage方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.FreePage方法的具体用法?C# Transaction.FreePage怎么用?C# Transaction.FreePage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Voron.Impl.Transaction的用法示例。


在下文中一共展示了Transaction.FreePage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteTree

	    public void DeleteTree(Transaction tx, string name)
        {
            if (tx.Flags == (TransactionFlags.ReadWrite) == false)
                throw new ArgumentException("Cannot create a new newRootTree with a read only transaction");

	        Tree tree = tx.ReadTree(name);
	        if (tree == null)
	            return;

            foreach (var page in tree.AllPages())
            {
                tx.FreePage(page);
            }

            tx.State.Root.Delete((Slice) name);

            tx.RemoveTree(name);
        }
开发者ID:VPashkov,项目名称:ravendb,代码行数:18,代码来源:StorageEnvironment.cs

示例2: TryOverwriteOverflowPages

		private bool TryOverwriteOverflowPages(Transaction tx, TreeMutableState treeState, NodeHeader* updatedNode,
													  Slice key, int len, ushort? version, out byte* pos)
		{
			if (updatedNode->Flags == NodeFlags.PageRef &&
				tx.Id <= tx.Environment.OldestTransaction) // ensure MVCC - do not overwrite if there is some older active transaction that might read those overflows
			{
				var overflowPage = tx.GetReadOnlyPage(updatedNode->PageNumber);

				if (len <= overflowPage.OverflowSize)
				{
					CheckConcurrency(key, version, updatedNode->Version, TreeActionType.Add);

					if (updatedNode->Version == ushort.MaxValue)
						updatedNode->Version = 0;
					updatedNode->Version++;

					var availableOverflows = tx.DataPager.GetNumberOfOverflowPages(overflowPage.OverflowSize);

					var requestedOverflows = tx.DataPager.GetNumberOfOverflowPages(len);

					var overflowsToFree = availableOverflows - requestedOverflows;

					for (int i = 0; i < overflowsToFree; i++)
					{
						tx.FreePage(overflowPage.PageNumber + requestedOverflows + i);
					}

					treeState.OverflowPages -= overflowsToFree;
					treeState.PageCount -= overflowsToFree;

					overflowPage.OverflowSize = len;

					pos = overflowPage.Base + Constants.PageHeaderSize;
					return true;
				}
			}
			pos = null;
			return false;
		}
开发者ID:paulcbetts,项目名称:ravendb,代码行数:39,代码来源:Tree.cs

示例3: MultiDelete

		public void MultiDelete(Transaction tx, Slice key, Slice value, ushort? version = null)
		{
			State.IsModified = true;
			Lazy<Cursor> lazy;
			var page = FindPageFor(tx, key, out lazy);
			if (page == null || page.LastMatch != 0)
			{
				return; //nothing to delete - key not found
			}

			page = tx.ModifyPage(page.PageNumber, page);

			var item = page.GetNode(page.LastSearchPosition);

			if (item->Flags == NodeFlags.MultiValuePageRef) //multi-value tree exists
			{
				var tree = OpenOrCreateMultiValueTree(tx, key, item);

				tree.Delete(tx, value, version);

				// previously, we would convert back to a simple model if we dropped to a single entry
				// however, it doesn't really make sense, once you got enough values to go to an actual nested 
				// tree, you are probably going to remain that way, or be removed completely.
				if (tree.State.EntriesCount != 0) 
					return;
				tx.TryRemoveMultiValueTree(this, key);
				tx.FreePage(tree.State.RootPageNumber);
				Delete(tx, key);
			}
			else // we use a nested page here
			{
				var nestedPage = new Page(NodeHeader.DirectAccess(tx, item), "multi tree", (ushort)NodeHeader.GetDataSize(tx, item));
				var nestedItem = nestedPage.Search(value, NativeMethods.memcmp);
				if (nestedItem == null) // value not found
					return;

				CheckConcurrency(key, value, version, nestedItem->Version, TreeActionType.Delete);
				nestedPage.RemoveNode(nestedPage.LastSearchPosition);
				if (nestedPage.NumberOfEntries == 0)
					Delete(tx, key);
			}
		}
开发者ID:paulcbetts,项目名称:ravendb,代码行数:42,代码来源:Tree.MultiTree.cs

示例4: RemoveLeafNode

		private void RemoveLeafNode(Transaction tx, Page page, out ushort nodeVersion)
		{
			var node = page.GetNode(page.LastSearchPosition);
			nodeVersion = node->Version;
			if (node->Flags == (NodeFlags.PageRef)) // this is an overflow pointer
			{
				var overflowPage = tx.GetReadOnlyPage(node->PageNumber);
				var numberOfPages = tx.DataPager.GetNumberOfOverflowPages(overflowPage.OverflowSize);
				for (int i = 0; i < numberOfPages; i++)
				{
					tx.FreePage(overflowPage.PageNumber + i);
				}

				State.OverflowPages -= numberOfPages;
				State.PageCount -= numberOfPages;
			}
			page.RemoveNode(page.LastSearchPosition);
		}
开发者ID:paulcbetts,项目名称:ravendb,代码行数:18,代码来源:Tree.cs

示例5: MultiDelete

	    public void MultiDelete(Transaction tx, Slice key, Slice value, ushort? version = null)
	    {
		    State.IsModified = true;
			Lazy<Cursor> lazy;
		    var page = FindPageFor(tx, key, out lazy);
		    if (page == null || page.LastMatch != 0)
		    {
			    return; //nothing to delete - key not found
		    }

			page = tx.ModifyPage(page.PageNumber, page);

		    var item = page.GetNode(page.LastSearchPosition);

		    if (item->Flags == NodeFlags.MultiValuePageRef) //multi-value tree exists
		    {
			    var tree = OpenOrCreateMultiValueTree(tx, key, item);

			    tree.Delete(tx, value, version);

			    if (tree.State.EntriesCount > 1)
				    return;
			    // convert back to simple key/val
			    var iterator = tree.Iterate(tx);
			    if (!iterator.Seek(Slice.BeforeAllKeys))
				    throw new InvalidDataException(
					    "MultiDelete() failed : sub-tree is empty where it should not be, this is probably a Voron bug.");

			    var dataToSave = iterator.CurrentKey;

			    var ptr = DirectAdd(tx, key, dataToSave.Size);
			    dataToSave.CopyTo(ptr);

			    tx.TryRemoveMultiValueTree(this, key);
			    tx.FreePage(tree.State.RootPageNumber);
		    }
		    else //the regular key->value pattern
		    {
			    Delete(tx, key, version);
		    }
	    }
开发者ID:randacc,项目名称:ravendb,代码行数:41,代码来源:Tree.cs


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