• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# KVDBLayer.InMemoryFileCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: PrefixWithFindPrevKeyWorks

 public void PrefixWithFindPrevKeyWorks()
 {
     using (var fileCollection = new InMemoryFileCollection())
     using (IKeyValueDB db = new KeyValueDB(fileCollection))
     {
         using (var tr = db.StartTransaction())
         {
             tr.CreateKey(_key1);
             tr.CreateKey(Key2);
             tr.SetKeyPrefix(ByteBuffer.NewAsync(Key2, 0, 1));
             Assert.True(tr.FindFirstKey());
             Assert.False(tr.FindPreviousKey());
             tr.Commit();
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:16,代码来源:KeyValueDBTest.cs


示例17: FindKeyWithPreferPreviousKeyWorks

 public void FindKeyWithPreferPreviousKeyWorks()
 {
     const int keyCount = 10000;
     using (var fileCollection = new InMemoryFileCollection())
     using (IKeyValueDB db = new KeyValueDB(fileCollection))
     {
         using (var tr = db.StartTransaction())
         {
             var key = new byte[100];
             for (int i = 0; i < keyCount; i++)
             {
                 key[0] = (byte)(i / 256);
                 key[1] = (byte)(i % 256);
                 tr.CreateKey(key);
             }
             tr.Commit();
         }
         using (var tr = db.StartTransaction())
         {
             var key = new byte[101];
             for (int i = 0; i < keyCount; i++)
             {
                 key[0] = (byte)(i / 256);
                 key[1] = (byte)(i % 256);
                 var findKeyResult = tr.Find(ByteBuffer.NewSync(key));
                 Assert.Equal(FindResult.Previous, findKeyResult);
                 Assert.Equal(i, tr.GetKeyIndex());
             }
         }
         using (var tr = db.StartTransaction())
         {
             var key = new byte[99];
             for (int i = 0; i < keyCount; i++)
             {
                 key[0] = (byte)(i / 256);
                 key[1] = (byte)(i % 256);
                 var findKeyResult = tr.Find(ByteBuffer.NewSync(key));
                 if (i == 0)
                 {
                     Assert.Equal(FindResult.Next, findKeyResult);
                     Assert.Equal(i, tr.GetKeyIndex());
                 }
                 else
                 {
                     Assert.Equal(FindResult.Previous, findKeyResult);
                     Assert.Equal(i - 1, tr.GetKeyIndex());
                 }
             }
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:51,代码来源:KeyValueDBTest.cs


示例18: FindLastKeyWorks

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


示例19: ReadOnlyTransactionThrowsOnWriteAccess

        public void ReadOnlyTransactionThrowsOnWriteAccess()
        {
            using (var fileCollection = new InMemoryFileCollection())
            using (IKeyValueDB db = new KeyValueDB(fileCollection))
            {
                using (var tr = db.StartReadOnlyTransaction())
                {
                    Assert.Throws<BTDBTransactionRetryException>(() => tr.CreateKey(new byte[1]));
                }
            }

        }
开发者ID:Bobris,项目名称:BTDB,代码行数:12,代码来源:KeyValueDBTest.cs


示例20: RepairsOnReopen

 public void RepairsOnReopen()
 {
     using (var fileCollection = new InMemoryFileCollection())
     {
         using (IKeyValueDB db = new KeyValueDB(fileCollection))
         {
             using (var tr = db.StartTransaction())
             {
                 tr.CreateKey(_key1);
                 tr.Commit();
             }
             using (var tr = db.StartTransaction())
             {
                 tr.CreateKey(Key2);
                 tr.Commit();
             }
             using (var tr = db.StartTransaction())
             {
                 tr.CreateKey(_key3);
                 // rollback
             }
             using (IKeyValueDB db2 = new KeyValueDB(fileCollection))
             {
                 using (var tr = db2.StartTransaction())
                 {
                     Assert.True(tr.FindExactKey(_key1));
                     Assert.True(tr.FindExactKey(Key2));
                     Assert.False(tr.FindExactKey(_key3));
                 }
             }
         }
         using (IKeyValueDB db = new KeyValueDB(fileCollection))
         {
             using (var tr = db.StartTransaction())
             {
                 Assert.True(tr.FindExactKey(_key1));
                 Assert.True(tr.FindExactKey(Key2));
                 Assert.False(tr.FindExactKey(_key3));
             }
         }
     }
 }
开发者ID:Bobris,项目名称:BTDB,代码行数:42,代码来源:KeyValueDBTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Pagination.PaginationQueryCondition类代码示例发布时间:2022-05-24
下一篇:
C# Diagnostics.ModuleProc类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap