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


C# StorageEnvironment.RenameTree方法代码示例

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


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

示例1: Record_debug_journal_and_replay_it


//.........这里部分代码省略.........
					writeBatch.MultiAdd("multi-foo", "CC", "test-tree");

					writeBatch.Delete("foo-bar", "test-tree");
					env.Writer.Write(writeBatch);
				}

				using (var tx = env.NewTransaction(TransactionFlags.ReadWrite))
				{
					env.CreateTree(tx, "test-tree2");
					tx.Commit();
				}

				using (var writeBatch = new WriteBatch())
				{
					var valueBuffer = new MemoryStream(Encoding.UTF8.GetBytes("testing testing 1!"));
					writeBatch.Add("foo", valueBuffer, "test-tree2");

					valueBuffer = new MemoryStream(Encoding.UTF8.GetBytes("testing testing 1 2!"));
					writeBatch.Add("bar", valueBuffer, "test-tree2");

					valueBuffer = new MemoryStream(Encoding.UTF8.GetBytes("testing testing 1 2 3!"));
					writeBatch.Add("foo-bar", valueBuffer, "test-tree2");
					env.Writer.Write(writeBatch);
				}

				using (var tx = env.NewTransaction(TransactionFlags.ReadWrite))
				{
					env.CreateTree(tx, "structures-tree");
					tx.Commit();
				}

				using (var writeBatch = new WriteBatch())
				{
					writeBatch.AddStruct("structs/1", new Structure<SampleStruct>(structSchema)
						.Set(SampleStruct.Foo, 13)
						.Set(SampleStruct.Bar, "debug journal testing"),
						"structures-tree");

					env.Writer.Write(writeBatch);
				}

				using (var tx = env.NewTransaction(TransactionFlags.ReadWrite))
				{
					env.CreateTree(tx, "rename-me");
					tx.Commit();
				}

				using (var writeBatch = new WriteBatch())
				{
					writeBatch.Add("item", "renaming tree test", "rename-me");

					env.Writer.Write(writeBatch);
				}

				using (var tx = env.NewTransaction(TransactionFlags.ReadWrite))
				{
					env.RenameTree(tx, "rename-me", "renamed");

					tx.Commit();
				}
			}

			using (var env = new StorageEnvironment(StorageEnvironmentOptions.CreateMemoryOnly()))
			{
				env.DebugJournal = DebugJournal.FromFile(debugJouralName, env);
				env.DebugJournal.Replay();

				using (var snapshot = env.CreateSnapshot())
				{
					Assert.Equal("{ \"title\": \"foo\",\"name\":\"bar\"}", snapshot.Read("test-tree", "foo").Reader.ToStringValue());
				    Assert.Equal("testing testing 1 2!", snapshot.Read("test-tree", "bar").Reader.ToStringValue());

				    Assert.Equal("testing testing 1!", snapshot.Read("test-tree2", "foo").Reader.ToStringValue());
				    Assert.Equal("testing testing 1 2!", snapshot.Read("test-tree2", "bar").Reader.ToStringValue());
				    Assert.Equal("testing testing 1 2 3!", snapshot.Read("test-tree2", "foo-bar").Reader.ToStringValue());

                    Assert.Equal(10, snapshot.Read("test-tree", "incr-key").Reader.ReadLittleEndianInt64());

					Assert.Equal(0,snapshot.ReadVersion("test-tree","foo-bar"));

					using (var iter = snapshot.MultiRead("test-tree","multi-foo"))
					{
						iter.Seek(Slice.BeforeAllKeys);
						Assert.Equal("AA",iter.CurrentKey.ToString());
						Assert.DoesNotThrow(() => iter.MoveNext());
						Assert.Equal("BB",iter.CurrentKey.ToString());
						Assert.DoesNotThrow(() => iter.MoveNext());
						Assert.Equal("CC",iter.CurrentKey.ToString());
					}

					var structReader = snapshot.ReadStruct("structures-tree", "structs/1", structSchema).Reader;

					Assert.Equal(13, structReader.ReadInt(SampleStruct.Foo));
					Assert.Equal("debug journal testing", structReader.ReadString(SampleStruct.Bar));

					Assert.Equal("renaming tree test", snapshot.Read("renamed", "item").Reader.ToStringValue());
				}
			}			

		}
开发者ID:jrusbatch,项目名称:ravendb,代码行数:101,代码来源:DebugJournalTest.cs


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