本文整理汇总了C#中Manifest.AddPage方法的典型用法代码示例。如果您正苦于以下问题:C# Manifest.AddPage方法的具体用法?C# Manifest.AddPage怎么用?C# Manifest.AddPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Manifest
的用法示例。
在下文中一共展示了Manifest.AddPage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateManifestFile
public void CreateManifestFile()
{
var path = Path.GetFullPath("TestData\\ManifestFileV1");
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
// Remove the file if it exists
var filename = Config.ManifestFile(path);
if (File.Exists(filename))
File.Delete(filename);
var mf = new Manifest(path);
mf.AddPage(1, 5, new KeyEx(new byte[] { 5 }, 5), new KeyEx(new byte[] { 5, 1 }, 5));
mf.AddPage(1, 6, new KeyEx(new byte[] { 6 }, 6), new KeyEx(new byte[] { 6, 1 }, 6));
mf.AddPage(1, 4, new KeyEx(new byte[] { 4 }, 4), new KeyEx(new byte[] { 4, 1 }, 4));
using (var mfSnap = mf.GetLatestManifest()) {
PageRecord[] pg = mfSnap.GetPagesAtLevel(1);
Assert.AreEqual(1, pg[0].Level);
Assert.AreEqual(4, pg[0].Version);
Assert.AreEqual(1, pg[1].Level);
Assert.AreEqual(5, pg[1].Version);
Assert.AreEqual(1, pg[2].Level);
Assert.AreEqual(6, pg[2].Version);
}
mf = new Manifest(path);
mf.ModifyPages(new List<PageRecord>{
new PageRecord(1, 8, new KeyEx( new byte[] { 16 }, 16), new KeyEx(new byte[] { 16, 1 }, 16) ),
new PageRecord(1, 9, new KeyEx( new byte[] { 1 }, 1), new KeyEx(new byte[] { 1, 1 }, 1) ),
new PageRecord(1, 16, new KeyEx( new byte[] { 10 }, 10), new KeyEx(new byte[] { 10, 1 }, 10) )
}, new List<PageRef>{
new PageRef{ Level = 1, Version = 6},
new PageRef{ Level = 1, Version = 4},
});
mf = new Manifest(path);
using (var mfSnap = mf.GetLatestManifest()) {
var pg = mfSnap.GetPagesAtLevel(1);
Assert.AreEqual(1, pg[0].Level);
Assert.AreEqual(9, pg[0].Version);
Assert.AreEqual(1, pg[1].Level);
Assert.AreEqual(5, pg[1].Version);
Assert.AreEqual(1, pg[2].Level);
Assert.AreEqual(16, pg[2].Version);
Assert.AreEqual(1, pg[3].Level);
Assert.AreEqual(8, pg[3].Version);
}
}
示例2: WriteToSortedBlockTable
public void WriteToSortedBlockTable(Manifest manifest)
{
// Closes journal file, we don't need it anymore.
_journal.Close ();
// Writes out the contents of the memtable to the level-0 sbt log.
_memTable.WriteToSortedBlockTable (_baseFileName, 0, _version);
// Commit the new pages to the manifest.
manifest.AddPage (0, _version, FirstKey, LastKey);
// Removes the journal file.
_journal.Delete ();
}
示例3: TestManifestSnapshot
public void TestManifestSnapshot()
{
var path = Path.GetFullPath ("TestData\\TestManifestSnapshot");
if (!Directory.Exists (path)) Directory.CreateDirectory (path);
// Remove the file if it exists
var filename = Config.ManifestFile (path);
if (File.Exists (filename)) File.Delete (filename);
var mf = new Manifest (path);
// Add pages and dummy files to represent their contents
mf.AddPage (1, 5, Key.FromBytes (new byte[] { 5 }), Key.FromBytes (new byte[] { 5, 1 }));
using (var file = new StreamWriter(Config.SortedBlockTableFile("TestData\\TestManifestSnapshot", 1, 5))) file.Write ("Test");
mf.AddPage (1, 6, Key.FromBytes (new byte[] { 6 }), Key.FromBytes (new byte[] { 6, 1 }));
using (var file = new StreamWriter(Config.SortedBlockTableFile("TestData\\TestManifestSnapshot", 1, 6))) file.Write ("Test");
mf.AddPage (1, 4, Key.FromBytes (new byte[] { 4 }), Key.FromBytes (new byte[] { 4, 1 }));
using (var file = new StreamWriter(Config.SortedBlockTableFile("TestData\\TestManifestSnapshot", 1, 4))) file.Write ("Test");
using (var manifestSnapshot = mf.GetLatestManifest()) {
mf.ModifyPages (new List<PageRecord> {
new PageRecord(1, 8, Key.FromBytes( new byte[] { 16 }), Key.FromBytes(new byte[] { 16, 1 }) ),
new PageRecord(1, 9, Key.FromBytes( new byte[] { 1 }), Key.FromBytes(new byte[] { 1, 1 }) ),
new PageRecord(1, 16, Key.FromBytes( new byte[] { 10 }), Key.FromBytes(new byte[] { 10, 1 }) )
}, new List<PageRef> {
new PageRef{ Level = 1, Version = 6},
new PageRef{ Level = 1, Version = 4},
});
PageRecord[] pg = manifestSnapshot.GetPagesAtLevel (1);
Assert.AreEqual (1, pg [0].Level);
Assert.AreEqual (4, pg [0].Version);
Assert.AreEqual (1, pg [1].Level);
Assert.AreEqual (5, pg [1].Version);
Assert.AreEqual (1, pg [2].Level);
Assert.AreEqual (6, pg [2].Version);
// The files should still exist for now
Assert.IsTrue (File.Exists (Config.SortedBlockTableFile ("TestData\\TestManifestSnapshot", 1, 4)));
Assert.IsTrue (File.Exists (Config.SortedBlockTableFile ("TestData\\TestManifestSnapshot", 1, 5)));
Assert.IsTrue (File.Exists (Config.SortedBlockTableFile ("TestData\\TestManifestSnapshot", 1, 6)));
}
// The files should be deleted now since we closed the snapshot
Assert.IsFalse (File.Exists (Config.SortedBlockTableFile ("TestData\\TestManifestSnapshot", 1, 4)));
Assert.IsTrue (File.Exists (Config.SortedBlockTableFile ("TestData\\TestManifestSnapshot", 1, 5)));
Assert.IsFalse (File.Exists (Config.SortedBlockTableFile ("TestData\\TestManifestSnapshot", 1, 6)));
}