// assumes that env != null internal LogCursor(Env env) { this.env = env; }
internal Txn(Env env) { this.env = env; // so that we can refer back to the Txn instance instanceHandle = GCHandle.Alloc(this, GCHandleType.WeakTrackResurrection); }
/// <summary> /// ��ʼ�� /// </summary> private void Init() { env = new Env(EnvCreateFlags.None); Env.OpenFlags envFlags = Env.OpenFlags.Create | Env.OpenFlags.InitLock | Env.OpenFlags.InitLog | Env.OpenFlags.InitMPool | Env.OpenFlags.InitTxn | Env.OpenFlags.Recover; env.Open(directory, envFlags, 0); txn = env.TxnBegin(null, Txn.BeginFlags.None); db = env.CreateDatabase(DbCreateFlags.None); btree = (DbHash)db.Open(txn, dbName, null, DbType.Hash, Db.OpenFlags.Create, 0); }
internal EnvCacheFile(Env env): base(new object()) { this.env = env; }
static CallbackStatus PageInOutWrapCLS(Env env, UInt32 pgno, void* pgaddr, ref DBT pgcookie, PageInOutFcn pgInOut) { // construct DbEntry for pgcookie int size = unchecked((int)pgcookie.size); // we are not using a shared buffer - the call-back might take // a long time and we do not want to lock the buffer that long byte[] buffer = new byte[size]; Marshal.Copy((IntPtr)pgcookie.data, buffer, 0, size); DbEntry cookieEntry = DbEntry.InOut(buffer, 0, size); cookieEntry.dbt.flags = pgcookie.flags; cookieEntry.dbt.dlen = pgcookie.dlen; cookieEntry.dbt.doff = pgcookie.doff; // call CLS compliant delegate - we assume it is not null return pgInOut(env, new CachePage(pgno, (IntPtr)pgaddr), ref cookieEntry); }
static CallbackStatus PageInOutWrapCLS(Env env, UInt32 pgno, void* pgaddr, ref DBT pgcookie, PageInOutFcn pgInOut) { IntPtr cookie = IntPtr.Zero; // extract IntPtr from DBT int size = unchecked((int)pgcookie.size); if (size != 0) { if (size != sizeof(IntPtr)) throw new BdbException("Invalid page cookie."); cookie = *(IntPtr*)pgcookie.data; } // call CLS compliant delegate - we assume it is not null return pgInOut(env, new CachePage(pgno, (IntPtr)pgaddr), cookie); }