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


C# Manifest.NextVersion方法代码示例

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


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

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

示例2: TestManifestFileRollover

        public void TestManifestFileRollover()
        {
            var path = Path.GetFullPath ("TestData\\TestManifestFileRollover");
            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);
            for (int i = 0; i < Config.ManifestVersionCount - 10; i++) {
                var level = mf.NextVersion (1);
                level.GetType ();
            }

            var manifestSize = new FileInfo (filename).Length;

            for (int i = 0; i < 30; i++) {
                var level = mf.NextVersion (1);
                level.GetType ();
            }

            var newManifestSize = new FileInfo (filename).Length;

            // The new file should be smaller than the previous one, because it should have rolled over.
            Assert.Less (newManifestSize, manifestSize);
        }
开发者ID:T145,项目名称:razordbx,代码行数:27,代码来源:ManifestTests.cs

示例3: WriteAndReadManifestMany

        public void WriteAndReadManifestMany()
        {
            var path = Path.GetFullPath ("TestData\\WriteAndReadManifestMany");
            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);
            Assert.AreEqual (0, mf.CurrentVersion (0));

            var timer = new Stopwatch ();
            timer.Start ();
            for (int i = 0; i < 1100; i++) Assert.AreEqual (i + 1, mf.NextVersion (0));
            timer.Stop ();

            Console.WriteLine ("Committed manifest update in average of {0} ms", (double)timer.ElapsedMilliseconds / 1100.0);

            var mf2 = new Manifest (path);
            Assert.AreEqual (1100, mf2.CurrentVersion (0));
        }
开发者ID:T145,项目名称:razordbx,代码行数:22,代码来源:ManifestTests.cs

示例4: WriteAndReadManifestThreaded

        public void WriteAndReadManifestThreaded()
        {
            var path = Path.GetFullPath ("TestData\\WriteAndReadManifestMulti");
            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);
            Assert.AreEqual (0, mf.CurrentVersion (0));

            int num_threads = 11;
            List<Thread> threads = new List<Thread> ();
            for (int t = 0; t < num_threads; t++) threads.Add (new Thread (() => { for (int i = 0; i < 100; i++) mf.NextVersion (0); }));

            var timer = new Stopwatch ();
            timer.Start ();
            threads.ForEach ((t) => t.Start ());
            threads.ForEach ((t) => t.Join ());
            timer.Stop ();

            Console.WriteLine ("Committed manifest update in average of {0} ms", (double)timer.ElapsedMilliseconds / 1100.0);

            var mf2 = new Manifest (path);
            Assert.AreEqual (1100, mf2.CurrentVersion (0));
        }
开发者ID:T145,项目名称:razordbx,代码行数:27,代码来源:ManifestTests.cs

示例5: WriteAndReadManifest

        public void WriteAndReadManifest()
        {
            var path = Path.GetFullPath ("TestData\\WriteAndReadManifest");
            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);
            Assert.AreEqual (path, mf.BaseFileName);
            Assert.AreEqual (0, mf.CurrentVersion (0));
            Assert.AreEqual (1, mf.NextVersion (0));
            Assert.AreEqual (1, mf.CurrentVersion (0));
            Assert.AreEqual (1, mf.ManifestVersion);

            var mf2 = new Manifest (path);
            Assert.AreEqual (0, mf2.ManifestVersion);
            Assert.AreEqual (1, mf2.CurrentVersion (0));
            Assert.AreEqual (2, mf2.NextVersion (0));
            Assert.AreEqual (2, mf2.CurrentVersion (0));
            Assert.AreEqual (1, mf2.ManifestVersion);
        }
开发者ID:T145,项目名称:razordbx,代码行数:24,代码来源:ManifestTests.cs


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