本文整理汇总了C#中BTDB.KVDBLayer.InMemoryFileCollection.GetCount方法的典型用法代码示例。如果您正苦于以下问题:C# InMemoryFileCollection.GetCount方法的具体用法?C# InMemoryFileCollection.GetCount怎么用?C# InMemoryFileCollection.GetCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTDB.KVDBLayer.InMemoryFileCollection
的用法示例。
在下文中一共展示了InMemoryFileCollection.GetCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddingContinueToNewFileAfterReopenWithCorruption
public void AddingContinueToNewFileAfterReopenWithCorruption()
{
using (var fileCollection = new InMemoryFileCollection())
{
using (IKeyValueDB db = new KeyValueDB(fileCollection))
{
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(_key1, _key1);
tr.Commit();
}
}
fileCollection.SimulateCorruptionBySetSize(20 + 16);
using (IKeyValueDB db = new KeyValueDB(fileCollection))
{
using (var tr = db.StartTransaction())
{
Assert.Equal(0, tr.GetKeyValueCount());
tr.CreateOrUpdateKeyValue(Key2, Key2);
tr.Commit();
}
Console.WriteLine(db.CalcStats());
}
Assert.True(2 <= fileCollection.GetCount());
}
}
示例2: AddingContinueToSameFileAfterReopen
public void AddingContinueToSameFileAfterReopen()
{
using (var fileCollection = new InMemoryFileCollection())
{
using (IKeyValueDB db = new KeyValueDB(fileCollection))
{
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(_key1, _key1);
tr.Commit();
}
}
using (IKeyValueDB db = new KeyValueDB(fileCollection))
{
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(Key2, Key2);
tr.Commit();
}
Console.WriteLine(db.CalcStats());
}
Assert.Equal(2u, fileCollection.GetCount()); // Log + Index
}
}
示例3: FastCleanUpOnStartRemovesUselessFiles
public void FastCleanUpOnStartRemovesUselessFiles()
{
using (var fileCollection = new InMemoryFileCollection())
{
using (var db = new KeyValueDB(fileCollection, new NoCompressionStrategy(), 1024))
{
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(_key1, new byte[1024]);
tr.CreateOrUpdateKeyValue(Key2, new byte[1024]);
tr.Commit();
}
using (var tr = db.StartTransaction())
{
tr.EraseAll();
tr.Commit();
}
Assert.Equal(3u, fileCollection.GetCount()); // 3 Logs
}
using (var db = new KeyValueDB(fileCollection, new NoCompressionStrategy(), 1024))
{
Console.WriteLine(db.CalcStats());
Assert.Equal(2u, fileCollection.GetCount()); // 1 Log, 1 KeyIndex
}
}
}
示例4: CompactionDoesNotRemoveStillUsedFiles
public void CompactionDoesNotRemoveStillUsedFiles()
{
using (var fileCollection = new InMemoryFileCollection())
{
using (var db = new KeyValueDB(fileCollection, new NoCompressionStrategy(), 1024, null))
{
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(_key1, new byte[1024]);
tr.CreateOrUpdateKeyValue(Key2, new byte[10]);
tr.Commit();
}
var longTr = db.StartTransaction();
using (var tr = db.StartTransaction())
{
tr.FindExactKey(_key1);
tr.EraseCurrent();
tr.Commit();
}
db.Compact(new CancellationToken());
Assert.Equal(3u, fileCollection.GetCount()); // 2 Logs, 1 KeyIndex
longTr.Dispose();
db.Compact(new CancellationToken());
Assert.Equal(2u, fileCollection.GetCount()); // 1 Log, 1 KeyIndex
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(_key3, new byte[10]);
tr.Commit();
}
using (var db2 = new KeyValueDB(fileCollection, new NoCompressionStrategy(), 1024))
{
using (var tr = db2.StartTransaction())
{
Assert.True(tr.FindExactKey(_key3));
}
}
}
}
}
示例5: AddingContinueToSameFileAfterReopenOfDBWith2TransactionLogFiles
public void AddingContinueToSameFileAfterReopenOfDBWith2TransactionLogFiles()
{
using (var fileCollection = new InMemoryFileCollection())
{
using (IKeyValueDB db = new KeyValueDB(fileCollection, new NoCompressionStrategy(), 1024))
{
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(_key1, new byte[1024]);
tr.CreateOrUpdateKeyValue(Key2, new byte[10]);
tr.Commit();
}
}
Assert.Equal(2u, fileCollection.GetCount());
using (IKeyValueDB db = new KeyValueDB(fileCollection, new NoCompressionStrategy(), 1024))
{
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(Key2, new byte[1024]);
tr.CreateOrUpdateKeyValue(_key3, new byte[10]);
tr.Commit();
}
}
Assert.Equal(4u, fileCollection.GetCount());
using (IKeyValueDB db = new KeyValueDB(fileCollection, new NoCompressionStrategy(), 1024))
{
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(Key2, Key2);
tr.Commit();
}
}
Assert.Equal(4u, fileCollection.GetCount());
}
}
示例6: CompactionWaitsForFinishingOldTransactionsBeforeRemovingFiles
public void CompactionWaitsForFinishingOldTransactionsBeforeRemovingFiles()
{
using (var fileCollection = new InMemoryFileCollection())
{
using (var db = new KeyValueDB(fileCollection, new NoCompressionStrategy(), 1024))
{
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(_key1, new byte[1024]);
tr.CreateOrUpdateKeyValue(Key2, new byte[10]);
tr.Commit();
}
var longTr = db.StartTransaction();
using (var tr = db.StartTransaction())
{
tr.FindExactKey(_key1);
tr.EraseCurrent();
tr.Commit();
}
db.Compact();
Thread.Sleep(2000);
Console.WriteLine(db.CalcStats());
Assert.True(4 <= fileCollection.GetCount()); // 2 Logs, 1 Value, 1 KeyIndex, (optinal 1 Unknown (old KeyIndex))
longTr.Dispose();
Thread.Sleep(1000);
Assert.Equal(2u, fileCollection.GetCount()); // 1 Log, 1 KeyIndex
using (var tr = db.StartTransaction())
{
tr.CreateOrUpdateKeyValue(_key3, new byte[10]);
tr.Commit();
}
using (var db2 = new KeyValueDB(fileCollection, new NoCompressionStrategy(), 1024))
{
using (var tr = db2.StartTransaction())
{
Assert.True(tr.FindExactKey(_key3));
}
}
}
}
}