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


C# Transaction.RemoveTree方法代码示例

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


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

示例1: RenameTree

	    public unsafe void RenameTree(Transaction tx, string fromName, string toName)
	    {
			if (tx.Flags == (TransactionFlags.ReadWrite) == false)
				throw new ArgumentException("Cannot rename a new tree with a read only transaction");

			if (toName.Equals(Constants.RootTreeName, StringComparison.InvariantCultureIgnoreCase) ||
				toName.Equals(Constants.FreeSpaceTreeName, StringComparison.InvariantCultureIgnoreCase))
				throw new InvalidOperationException("Cannot create a tree with reserved name: " + toName);

		    if (tx.ReadTree(toName) != null)
			    throw new ArgumentException("Cannot rename a tree with the name of an existing tree: " + toName);

		    Tree fromTree = tx.ReadTree(fromName);
		    if (fromTree == null)
			    throw new ArgumentException("Tree " + fromName + " does not exists");

            Slice key = (Slice)toName;

	        tx.State.Root.Delete((Slice)fromName);
			var ptr = tx.State.Root.DirectAdd(key, sizeof(TreeRootHeader));
		    fromTree.State.CopyTo((TreeRootHeader*) ptr);
		    fromTree.Name = toName;
		    fromTree.State.IsModified = true;
		    
			tx.RemoveTree(fromName);
			tx.RemoveTree(toName);

			tx.AddTree(toName, fromTree);

			if (IsDebugRecording)
                DebugJournal.RecordWriteAction(DebugActionType.RenameTree, tx, (Slice)toName, fromName, Stream.Null);
	    }
开发者ID:VPashkov,项目名称:ravendb,代码行数:32,代码来源:StorageEnvironment.cs

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


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