public static BinaryObjectDatabase <T> OpenFile <T>(string filename, bool useUnsafeMemoryManager) { var db = new BinaryObjectDatabase <T>(filename, useUnsafeMemoryManager); db.Open(); return(db); }
public static BinaryObjectDatabase <T> OpenFile <T>(string filename) { var db = new BinaryObjectDatabase <T>(filename); db.Open(); return(db); }
public static BinaryObjectDatabase <T> OpenFile <T>() { var db = new BinaryObjectDatabase <T>(); db.Open(); return(db); }
private BinDB TestBenchmarkDB( bool useUnsafeMemoryManager, bool setEntityMetaData, bool trackEntities, bool isReadOnly, Action <BinDB> action) => BinaryObjectDatabase .OpenFile(_dbFile, useUnsafeMemoryManager) .Set(setEntityMetaData, trackEntities, isReadOnly) .Do(action);
protected void TestConcurrency( bool setEntityMetaData, bool trackEntities, bool isReadOnly, int pageSize, Func <int, Widget> createWidget, bool checkContains = true, bool noFragmentation = true, Action <BinDB, Widget, int> concurrentAction = null, Action <BinDB, List <Widget> > finalize = null, int count = 0x100) { var dbFile = Context.NextDBName(); BinDB nextDb() => BinaryObjectDatabase .OpenFile(dbFile) .Set(setEntityMetaData, trackEntities, false, pageSize) .Do(x => x.AssertNoFragmentation()); var dbs = Enumerable.Range(0, 8).Select(x => nextDb()).ToArray(); try { BinDB getDB() => dbs.TakeRandom(); void For(Action <int> action) => Parallel.For(0, count, action); For(i => getDB().Create(createWidget(i).Do(y => y.X = i))); dbs.For(x => x.IsReadOnly = isReadOnly); List <Widget> getRows() => getDB().ReadUnsafe().Cast <Widget>().ToList(); var rows = getRows(); if (concurrentAction != null) { For(i => concurrentAction(getDB(), rows[i], i)); } finalize?.Invoke(getDB(), getRows()); AreEqual(count, rows.Distinct(x => x.X).Count()); AreEqual(count, rows.Count()); if (checkContains) { Contains(Widget, rows); } CollectionAssert.AreEqual(rows, getRows()); getDB().ReadMemoryManagerUnsafe() .Do(x => AreEqual(count, x.Allocations.Count)) .DoIf(noFragmentation, x => x.AssertNoFragmentation(), x => x.AssertFragmentation()); } finally { dbs.For(x => x.Dispose()); File.Delete(dbFile); File.Delete(Path.ChangeExtension(dbFile, "odm")); } }
public BinDB NextDB() => CurrentDB = BinaryObjectDatabase.OpenFile(NextDBName());