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


C# InMemoryFileCollection.GetCount方法代码示例

本文整理汇总了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());
     }
 }
开发者ID:tomasdeml,项目名称:BTDB,代码行数:26,代码来源:KeyValueDBTest.cs

示例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
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:24,代码来源:KeyValueDBTest.cs

示例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
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:26,代码来源:KeyValueDBTest.cs

示例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));
                 }
             }
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:39,代码来源:KeyValueDBTest.cs

示例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());
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:35,代码来源:KeyValueDBTest.cs

示例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));
                 }
             }
         }
     }
 }
开发者ID:tomasdeml,项目名称:BTDB,代码行数:41,代码来源:KeyValueDBTest.cs


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