本文整理汇总了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;
}
示例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);
}
示例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));
}
示例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));
}
示例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);
}