Example #1
0
 void OpenDB()
 {
     _lowDB = new KeyValueDB();
     _lowDB.Open(_dbstream, false);
     _db = new ObjectDB();
     _db.Open(_lowDB, true);
 }
Example #2
0
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false,
              new DBOptions().WithoutAutoRegistration()
              .WithFieldHandlerLogger(new DefaultFieldHandlerLogger(s => _fieldHandlerLoggerMessages.Add(s))));
 }
Example #3
0
 void OpenDb()
 {
     _logger = new LoggerMock();
     _db     = new ObjectDB {
         Logger = _logger
     };
     _db.Open(_lowDb, false, new DBOptions().WithoutAutoRegistration().WithSelfHealing());
 }
Example #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();
        }
Example #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
     })));
 }
Example #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
     })));
 }
Example #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();
     }
 }
Example #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();
 }
Example #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();
            }
        }
Example #10
0
 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();
     }
 }
Example #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();
            }
        }
Example #12
0
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false);
 }
Example #13
0
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false);
 }
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false, new DBOptions().WithoutAutoRegistration());
 }
Example #15
0
 void OpenDb()
 {
     _db = new ObjectDB();
     _db.Open(_lowDb, false, new DBOptions().WithoutAutoRegistration().WithCustomType2NameRegistry(_registry));
 }
Example #16
0
 void OpenDB()
 {
     _lowDB = new KeyValueDB();
     _lowDB.Open(_dbstream, false);
     _db = new ObjectDB();
     _db.Open(_lowDB, true);
 }