コード例 #1
0
ファイル: ObjectDBTest.cs プロジェクト: quyenbc/BTDB
 void OpenDB()
 {
     _lowDB = new KeyValueDB();
     _lowDB.Open(_dbstream, false);
     _db = new ObjectDB();
     _db.Open(_lowDB, true);
 }
コード例 #2
0
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false,
              new DBOptions().WithoutAutoRegistration()
              .WithFieldHandlerLogger(new DefaultFieldHandlerLogger(s => _fieldHandlerLoggerMessages.Add(s))));
 }
コード例 #3
0
 void OpenDb()
 {
     _logger = new LoggerMock();
     _db     = new ObjectDB {
         Logger = _logger
     };
     _db.Open(_lowDb, false, new DBOptions().WithoutAutoRegistration().WithSelfHealing());
 }
コード例 #4
0
        public void GlobalSetup()
        {
            _db = new ObjectDB();
            var directory = Path.Combine(Directory.GetCurrentDirectory(), "BTDBDist");

            Directory.CreateDirectory(directory);

            Console.WriteLine($"GlobalSetup, db: {directory}");
            _db.Open(new KeyValueDB(new OnDiskFileCollection(directory)), true);

            using var tr = _db.StartTransaction();
            _creator     = tr.InitRelation <IPersonTable>("Person");
            var personTable = _creator(tr);

            if (personTable.CountByCountry(Country.Czech) > 0)
            {
                return;
            }
            var nationality   = Country.Czech;
            var slovakiaCount = 0;
            var czechCount    = 0;

            for (ulong i = 0; i < TotalRecords; i++)
            {
                personTable.Insert(new Person(i, $"Name{i}", nationality, 0));

                if (i % 2 == 0 && slovakiaCount < SlovakiaTotal)
                {
                    nationality = Country.Slovakia;
                    slovakiaCount++;
                }
                else if (czechCount < CzechTotal)
                {
                    nationality = Country.Czech;
                    czechCount++;
                }
                else
                {
                    nationality = nationality switch
                    {
                        Country.Czech => Country.Poland,
                        Country.Poland => Country.Germany,
                        Country.Germany => Country.Poland,
                        Country.Slovakia => Country.Poland,
                        _ => nationality
                    };
                }
            }

            foreach (var countryType in Enum.GetValues(typeof(Country)))
            {
                var count = personTable.CountByCountry((Country)countryType);
                Console.WriteLine($"{(Country) countryType} Total: {count}");
            }

            tr.Commit();
        }
コード例 #5
0
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false,
              new DBOptions().WithSymmetricCipher(new AesGcmSymmetricCipher(new byte[]
     {
         0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
         27, 28, 29, 30, 31
     })));
 }
コード例 #6
0
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false, new DBOptions()
              .WithoutAutoRegistration()
              .WithFieldHandlerLogger(new DefaultFieldHandlerLogger(s => _fieldHandlerLoggerMessages.Add(s)))
              .WithSymmetricCipher(new AesGcmSymmetricCipher(new byte[]
     {
         0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
         27, 28, 29, 30, 31
     })));
 }
コード例 #7
0
 public void StartRelationTransaction()
 {
     using (var tr = db.StartTransaction())
     {
         db.Open(kvDb, false);
         creator = tr.InitRelation <IPersonTable>("Person");
         var personTable = creator(tr);
         personTable.Insert(new Person {
             Id = 2, Name = "admin", Age = 100
         });
         tr.Commit();
     }
 }
コード例 #8
0
 public void Test()
 {
     using (var tr = _db.StartTransaction())
     {
         _db.Open(_lowDb, false);
         var creator     = tr.InitRelation <IPersonTable>("Person");
         var personTable = creator(tr);
         personTable.Insert(new Person {
             Id = 2, Name = "admin", Age = 100
         });
         tr.Commit();
     }
     ReopenDb();
 }
コード例 #9
0
        public PersistentBuildCache(string dir)
        {
            var cacheIndex = 0;

            while (cacheIndex < 100)
            {
                _mutex = new Mutex(false, @"Global\bbcoreCache" + cacheIndex);
                if (_mutex.WaitOne(10))
                {
                    break;
                }
                _mutex.Dispose();
                _mutex = null;
                cacheIndex++;
            }
            if (_mutex == null)
            {
                return;
            }
            _dir = dir + "/cache" + (cacheIndex == 0 ? "" : cacheIndex.ToString());
            if (!new DirectoryInfo(_dir).Exists)
            {
                Directory.CreateDirectory(_dir);
            }

            _diskFileCollection = new OnDiskFileCollection(_dir);
            _kvdb = new KeyValueDB(new KeyValueDBOptions
            {
                FileCollection = _diskFileCollection,
                Compression    = new SnappyCompressionStrategy(),
                FileSplitSize  = 100000000
            });
            _odb = new ObjectDB();
            _odb.Open(_kvdb, false);
            using (var tr = _odb.StartWritingTransaction().Result)
            {
                _tsConfiguration = tr.InitRelation <ITSConfigurationTable>("tsconf");
                _tsRelation      = tr.InitRelation <ITSFileBuildCacheTable>("ts");
                _tsHashedContent = tr.InitRelation <IHashedContentTable>("hashedContent");
                tr.Commit();
            }
        }
コード例 #10
0
ファイル: MultiCoreDBTest.cs プロジェクト: srsman/BTDB
 void Initialize()
 {
     _dbdir = Path.GetTempPath() + "/deleteMeDB";
     Directory.Delete(_dbdir, true);
     Directory.CreateDirectory(_dbdir);
     _fc   = new OnDiskFileCollection(_dbdir);
     _kvdb = new KeyValueDB(new KeyValueDBOptions
     {
         Compression    = new SnappyCompressionStrategy(),
         FileSplitSize  = 100 * 1024 * 1024,
         FileCollection = _fc
     });
     _kvdb.Logger = this;
     _odb         = new ObjectDB();
     _odb.Open(_kvdb, false);
     using (var tr = _odb.StartWritingTransaction().GetAwaiter().GetResult())
     {
         _personRelation = tr.InitRelation <IPersonTable>("Person");
         tr.Commit();
     }
 }
コード例 #11
0
        public PersistentBuildCache(string dir)
        {
            _dir = dir + "/cache";
            if (!new DirectoryInfo(_dir).Exists)
            {
                Directory.CreateDirectory(_dir);
            }

            _diskFileCollection = new OnDiskFileCollection(_dir);
            _kvdb = new KeyValueDB(new KeyValueDBOptions {
                FileCollection = _diskFileCollection,
                Compression    = new SnappyCompressionStrategy(),
                FileSplitSize  = 100000000
            });
            _odb = new ObjectDB();
            _odb.Open(_kvdb, false);
            using (var tr = _odb.StartWritingTransaction().Result)
            {
                _tsConfiguration = tr.InitRelation <ITSConfigurationTable>("tsconf");
                _tsRelation      = tr.InitRelation <ITSFileBuildCacheTable>("ts");
                tr.Commit();
            }
        }
コード例 #12
0
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false);
 }
コード例 #13
0
ファイル: ODBIteratorTest.cs プロジェクト: Xamarui/BTDB
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false);
 }
コード例 #14
0
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false, new DBOptions().WithoutAutoRegistration());
 }
コード例 #15
0
ファイル: FindUnusedKeysTest.cs プロジェクト: yardee/BTDB
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false, new DBOptions().WithoutAutoRegistration().WithCustomType2NameRegistry(_registry));
 }
コード例 #16
0
ファイル: ObjectDBTest.cs プロジェクト: quyenbc/BTDB
 void OpenDB()
 {
     _lowDB = new KeyValueDB();
     _lowDB.Open(_dbstream, false);
     _db = new ObjectDB();
     _db.Open(_lowDB, true);
 }