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


C# KVDBLayer.InMemoryFileCollection类代码示例

本文整理汇总了C#中BTDB.KVDBLayer.InMemoryFileCollection的典型用法代码示例。如果您正苦于以下问题:C# InMemoryFileCollection类的具体用法?C# InMemoryFileCollection怎么用?C# InMemoryFileCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InMemoryFileCollection类属于BTDB.KVDBLayer命名空间,在下文中一共展示了InMemoryFileCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateEmptyDatabase

 public void CreateEmptyDatabase()
 {
     using (var fileCollection = new InMemoryFileCollection())
     using (new KeyValueDB(fileCollection))
     {
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:7,代码来源:KeyValueDBTest.cs

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

示例3: CreateEmptyCache

 public void CreateEmptyCache()
 {
     using (var fileCollection = new InMemoryFileCollection())
     using (new DiskChunkCache(fileCollection, 20, 1000))
     {
     }
 }
开发者ID:mano-cz,项目名称:BTDB,代码行数:7,代码来源:DiskChunkCacheTest.cs

示例4: GetFromEmptyCacheReturnsEmptyByteBuffer

 public void GetFromEmptyCacheReturnsEmptyByteBuffer()
 {
     using (var fileCollection = new InMemoryFileCollection())
     using (var cache = new DiskChunkCache(fileCollection, 20, 1000))
     {
         Assert.AreEqual(0, cache.Get(CalcHash(new byte[] { 0 })).Result.Length);
     }
 }
开发者ID:mano-cz,项目名称:BTDB,代码行数:8,代码来源:DiskChunkCacheTest.cs

示例5: EmptyWritingTransaction

 public void EmptyWritingTransaction()
 {
     using (var fileCollection = new InMemoryFileCollection())
     using (IKeyValueDB db = new KeyValueDB(fileCollection))
     {
         using (var tr = db.StartWritingTransaction().Result)
         {
             tr.Commit();
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:11,代码来源:KeyValueDBTest.cs

示例6: FirstTransaction

 public void FirstTransaction()
 {
     using (var fileCollection = new InMemoryFileCollection())
     using (IKeyValueDB db = new KeyValueDB(fileCollection))
     {
         using (var tr = db.StartTransaction())
         {
             Assert.True(tr.CreateOrUpdateKeyValue(ByteBuffer.NewAsync(_key1), ByteBuffer.NewAsync(new byte[0])));
             tr.Commit();
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:12,代码来源:KeyValueDBTest.cs

示例7: CanGetSizeOfPair

 public void CanGetSizeOfPair()
 {
     using (var fileCollection = new InMemoryFileCollection())
     using (IKeyValueDB db = new KeyValueDB(fileCollection))
     {
         using (var tr = db.StartTransaction())
         {
             tr.CreateOrUpdateKeyValue(ByteBuffer.NewAsync(_key1), ByteBuffer.NewAsync(new byte[1]));
             var s = tr.GetStorageSizeOfCurrentKey();
             Assert.Equal((uint)_key1.Length, s.Key);
             Assert.Equal(1u, s.Value);
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:14,代码来源:KeyValueDBTest.cs

示例8: GettingContentMakesItStayLongerDecreasingRate

 public void GettingContentMakesItStayLongerDecreasingRate()
 {
     using (var fileCollection = new InMemoryFileCollection())
     {
         const int cacheCapacity = 50000;
         using (var cache = new DiskChunkCache(fileCollection, 20, cacheCapacity))
         {
             for (var i = 0; i < 80; i++)
             {
                 Put(cache, i);
                 for (var j = 0; j < 79 - i; j++)
                     Get(cache, i);
                 Assert.LessOrEqual(fileCollection.Enumerate().Sum(f => (long)f.GetSize()), cacheCapacity);
             }
             Console.WriteLine(cache.CalcStats());
             Assert.True(Get(cache, 0));
             Assert.False(Get(cache, 60));
         }
     }
 }
开发者ID:mano-cz,项目名称:BTDB,代码行数:20,代码来源:DiskChunkCacheTest.cs

示例9: AccessEveryTenthTenTimesMoreMakesItStay

 public void AccessEveryTenthTenTimesMoreMakesItStay()
 {
     using (var fileCollection = new InMemoryFileCollection())
     {
         const int cacheCapacity = 50000;
         using (var cache = new DiskChunkCache(fileCollection, 20, cacheCapacity))
         {
             for (var i = 0; i < 46; i++)
             {
                 Put(cache, i);
                 for (var j = 0; j < (i % 5 == 0 ? 10 + i : 1); j++)
                     Get(cache, i);
                 if (i==42) Thread.Sleep(500);
                 Assert.LessOrEqual(fileCollection.Enumerate().Sum(f => (long)f.GetSize()), cacheCapacity);
             }
             Console.WriteLine(cache.CalcStats());
             Assert.True(Get(cache, 0));
             Assert.False(Get(cache, 1));
         }
     }
 }
开发者ID:mano-cz,项目名称:BTDB,代码行数:21,代码来源:DiskChunkCacheTest.cs

示例10: Run

 public void Run()
 {
     int cnt = 500000;
     using (var fc = new InMemoryFileCollection())
     using (var db = CreateDb(fc))
     {
         Measure("Relation: ", new RelationPersonTest(db, cnt));
     }
     using (var fc = new InMemoryFileCollection())
     using (var db = CreateDb(fc))
     {
         Measure("2 Maps: ", new SingletonPersonTest(db, cnt));
     }
     using (var db = CreateInMemoryDb())
     {
         Measure("Relation (mem): ", new RelationPersonTest(db, cnt));
     }
     using (var db = CreateInMemoryDb())
     {
         Measure("2 Maps (mem): ", new SingletonPersonTest(db, cnt));
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:22,代码来源:RelationSpeedTest.cs

示例11: 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:tomasdeml,项目名称:BTDB,代码行数:24,代码来源:KeyValueDBTest.cs

示例12: SetKeyPrefixInOneTransaction

 public void SetKeyPrefixInOneTransaction()
 {
     using (var fileCollection = new InMemoryFileCollection())
     using (IKeyValueDB db = new KeyValueDB(fileCollection))
     {
         var key = new byte[5];
         var value = new byte[100];
         var rnd = new Random();
         using (var tr = db.StartTransaction())
         {
             for (byte i = 0; i < 100; i++)
             {
                 key[0] = i;
                 for (byte j = 0; j < 100; j++)
                 {
                     key[4] = j;
                     rnd.NextBytes(value);
                     tr.CreateOrUpdateKeyValue(key, value);
                 }
             }
             tr.Commit();
         }
         using (var tr = db.StartTransaction())
         {
             for (byte i = 0; i < 100; i++)
             {
                 key[0] = i;
                 tr.SetKeyPrefix(ByteBuffer.NewSync(key, 0, 4));
                 Assert.Equal(100, tr.GetKeyValueCount());
             }
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:33,代码来源:KeyValueDBTest.cs

示例13: ALotOf5KbTransactionsWorks

 public void ALotOf5KbTransactionsWorks()
 {
     using (var fileCollection = new InMemoryFileCollection())
     using (IKeyValueDB db = new KeyValueDB(fileCollection))
     {
         for (int i = 0; i < 5000; i++)
         {
             var key = new byte[5000];
             using (var tr = db.StartTransaction())
             {
                 key[0] = (byte)(i / 256);
                 key[1] = (byte)(i % 256);
                 Assert.True(tr.CreateKey(key));
                 tr.Commit();
             }
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:18,代码来源:KeyValueDBTest.cs

示例14: AdvancedEraseRangeWorks

 void AdvancedEraseRangeWorks(int createKeys, int removeStart, int removeCount)
 {
     using (var fileCollection = new InMemoryFileCollection())
     using (IKeyValueDB db = new KeyValueDB(fileCollection))
     {
         var key = new byte[2];
         using (var tr = db.StartTransaction())
         {
             for (int i = 0; i < createKeys; i++)
             {
                 key[0] = (byte)(i / 256);
                 key[1] = (byte)(i % 256);
                 tr.CreateKey(key);
             }
             tr.Commit();
         }
         using (var tr = db.StartTransaction())
         {
             tr.EraseRange(removeStart, removeStart + removeCount - 1);
             Assert.Equal(createKeys - removeCount, tr.GetKeyValueCount());
             tr.Commit();
         }
         using (var tr = db.StartTransaction())
         {
             Assert.Equal(createKeys - removeCount, tr.GetKeyValueCount());
             for (int i = 0; i < createKeys; i++)
             {
                 key[0] = (byte)(i / 256);
                 key[1] = (byte)(i % 256);
                 if (i >= removeStart && i < removeStart + removeCount)
                 {
                     Assert.False(tr.FindExactKey(key), $"{i} should be removed");
                 }
                 else
                 {
                     Assert.True(tr.FindExactKey(key), $"{i} should be found");
                 }
             }
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:41,代码来源:KeyValueDBTest.cs

示例15: SimpleEraseCurrentWorks

 public void SimpleEraseCurrentWorks()
 {
     using (var fileCollection = new InMemoryFileCollection())
     using (IKeyValueDB db = new KeyValueDB(fileCollection))
     {
         using (var tr = db.StartTransaction())
         {
             tr.CreateKey(_key1);
             tr.CreateKey(Key2);
             tr.CreateKey(_key3);
             tr.EraseCurrent();
             Assert.True(tr.FindFirstKey());
             Assert.Equal(_key1, tr.GetKeyAsByteArray());
             Assert.True(tr.FindNextKey());
             Assert.Equal(Key2, tr.GetKeyAsByteArray());
             Assert.False(tr.FindNextKey());
             Assert.Equal(2, tr.GetKeyValueCount());
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:20,代码来源:KeyValueDBTest.cs


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