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


C# Manifest.GetLatestManifest方法代码示例

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


在下文中一共展示了Manifest.GetLatestManifest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
             }
        }
开发者ID:jburman,项目名称:razordb,代码行数:51,代码来源:FileFormatTests.cs

示例2: MergeTables

        public static IEnumerable<PageRecord> MergeTables(RazorCache cache, Manifest mf, int destinationLevel, IEnumerable<PageRef> tableSpecs, ExceptionHandling exceptionHandling, Action<string> logger)
        {
            var orderedTableSpecs = tableSpecs.OrderByPagePriority ();
            var outputTables = new List<PageRecord> ();
            SortedBlockTableWriter writer = null;

            Key firstKey = new Key ();
            Key lastKey = new Key ();
            Key maxKey = new Key (); // Maximum key we can span with this table to avoid covering more than 10 pages in the destination

            Action<KeyValuePair<Key, Value>> OpenPage = (pair) => {
                writer = new SortedBlockTableWriter (mf.BaseFileName, destinationLevel, mf.NextVersion (destinationLevel));
                firstKey = pair.Key;
                using (var m = mf.GetLatestManifest())
                    maxKey = m.FindSpanningLimit (destinationLevel + 1, firstKey);
            };

            Action ClosePage = () => {
                writer.Close ();
                outputTables.Add (new PageRecord (destinationLevel, writer.Version, firstKey, lastKey));
                writer = null;
            };

            foreach (var pair in EnumerateMergedTablesPreCached(cache, mf.BaseFileName, orderedTableSpecs, exceptionHandling, logger)) {
                if (writer == null)
                    OpenPage (pair);
                if (writer.WrittenSize >= Config.MaxSortedBlockTableSize || (!maxKey.IsEmpty && pair.Key.CompareTo (maxKey) >= 0))
                    ClosePage ();
                writer.WritePair (pair.Key, pair.Value);
                lastKey = pair.Key;
            }
            if (writer != null)
                ClosePage ();

            return outputTables;
        }
开发者ID:T145,项目名称:razordbx,代码行数:36,代码来源:SortedBlockTable.cs

示例3: V1ManifestFile

        public void V1ManifestFile()
        {
            var path = Path.GetFullPath(@"..\FormatTestData\V1");

             var 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(new KeyEx( new byte[] { 1 }, 1),pg[0].FirstKey);
                 Assert.AreEqual(new KeyEx(new byte[] { 1, 1 }, 1), pg[0].LastKey);
                 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);
             }
        }
开发者ID:jburman,项目名称:razordb,代码行数:20,代码来源:FileFormatTests.cs

示例4: 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)));
        }
开发者ID:T145,项目名称:razordbx,代码行数:47,代码来源:ManifestTests.cs


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