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


C# Transaction.TryRemoveMultiValueTree方法代码示例

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


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

示例1: 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

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