Esempio n. 1
0
 public BdbStorage(string path, string name = null, DatabaseEnvironment env = null)
 {
     _dbPAth = path;
     _env = env;
     _name = name;
     OpenBase();
 }
Esempio n. 2
0
        /*
         * Open environment, database and write data into database.
         * Generated log files are put under testHome.
         */
        public void Logging(string home, string dbName,
		    out DatabaseEnvironment env, out RecnoDatabase recnoDB)
        {
            string dbFileName = dbName + ".db";

            Configuration.ClearDir(home);

            // Open environment with logging subsystem.
            DatabaseEnvironmentConfig envConfig =
                new DatabaseEnvironmentConfig();
            envConfig.Create = true;
            envConfig.UseLogging = true;
            envConfig.LogSystemCfg = new LogConfig();
            envConfig.LogSystemCfg.FileMode = 755;
            envConfig.LogSystemCfg.ZeroOnCreate = true;
            envConfig.UseMPool = true;
            env = DatabaseEnvironment.Open(home, envConfig);

            /*
             * Open recno database, write 100000 records into
             * the database and close it.
             */
            RecnoDatabaseConfig recnoConfig =
                new RecnoDatabaseConfig();
            recnoConfig.Creation = CreatePolicy.IF_NEEDED;
            recnoConfig.Env = env;
            // The db needs mpool to open.
            recnoConfig.NoMMap = false;
            recnoDB = RecnoDatabase.Open(dbFileName,
                recnoConfig);
            for (int i = 0; i < 1000; i++)
                recnoDB.Append(new DatabaseEntry(
                    ASCIIEncoding.ASCII.GetBytes("key")));
        }
Esempio n. 3
0
 /// <summary>
 /// Create a new database object with the same underlying DB handle as
 /// <paramref name="clone"/>.  Used during Database.Open to get an
 /// object of the correct DBTYPE.
 /// </summary>
 /// <param name="clone">Database to clone</param>
 protected BaseDatabase(BaseDatabase clone) {
     db = clone.db;
     clone.db = null;
     db.api_internal = this;
     env = clone.env;
     clone.env = null;
 }
Esempio n. 4
0
        public static void LockingEnvSetUp(string testHome,
            string testName, out DatabaseEnvironment env,
            uint maxLock, uint maxLocker, uint maxObject,
            uint partition)
        {
            // Configure env and locking subsystem.
            LockingConfig lkConfig = new LockingConfig();
            /*
             * If the maximum number of locks/lockers/objects
             * is given, then the LockingConfig is set. Unless,
             * it is not set to any value.
             */
            if (maxLock != 0)
                lkConfig.MaxLocks = maxLock;
            if (maxLocker != 0)
                lkConfig.MaxLockers = maxLocker;
            if (maxObject != 0)
                lkConfig.MaxObjects = maxObject;
            if (partition != 0)
                lkConfig.Partitions = partition;

            DatabaseEnvironmentConfig envConfig =
                new DatabaseEnvironmentConfig();
            envConfig.Create = true;
            envConfig.LockSystemCfg = lkConfig;
            envConfig.UseLocking = true;
            envConfig.ErrorPrefix = testName;

            env = DatabaseEnvironment.Open(testHome, envConfig);
        }
Esempio n. 5
0
        /*
         * Configure and open hash databases for inverted index.
         */
        public InvertedIndex(DocumentsCatalogue documentsCatalogue, DatabaseEnvironment env)
        {
            this.documentsCatalogue = documentsCatalogue;
            this.env = env.env;
            /* Configure the database. */
            var hashDatabaseConfig = new HashDatabaseConfig()
            {
                Duplicates   = DuplicatesPolicy.NONE,
                Creation     = CreatePolicy.IF_NEEDED,
                FreeThreaded = true,
                CacheSize    = new CacheInfo(1, 0, 128),
                // Env = env.env,
            };

            /* Create the database if does not already exist and open the database file. */
            try
            {
                hashDatabase    = HashDatabase.Open("inverted_index.db", hashDatabaseConfig);
                maxFreqDatabase = HashDatabase.Open("max_freq.db", hashDatabaseConfig);
                //Console.WriteLine("{0} open.", dbFileName);
            }
            catch (Exception e)
            {
                // Console.WriteLine("Error opening {0}.", dbFileName);
                Console.WriteLine(e.Message);
                return;
            }
        }
Esempio n. 6
0
        public static void SetUpEnvWithTxnAndLocking(string envHome,
		    out DatabaseEnvironment env, out Transaction txn,
		    uint maxLock, uint maxLocker, uint maxObject, uint partition)
        {
            // Configure env and locking subsystem.
            LockingConfig lkConfig = new LockingConfig();

            /*
             * If the maximum number of locks/lockers/objects
             * is given, then the LockingConfig is set. Unless,
             * it is not set to any value.
             */
            if (maxLock != 0)
                lkConfig.MaxLocks = maxLock;
            if (maxLocker != 0)
                lkConfig.MaxLockers = maxLocker;
            if (maxObject != 0)
                lkConfig.MaxObjects = maxObject;
            if (partition != 0)
                lkConfig.Partitions = partition;

            DatabaseEnvironmentConfig envConfig =
                new DatabaseEnvironmentConfig();
            envConfig.Create = true;
            envConfig.UseTxns = true;
            envConfig.UseMPool = true;
            envConfig.LockSystemCfg = lkConfig;
            envConfig.UseLocking = true;
            envConfig.NoLocking = false;
            env = DatabaseEnvironment.Open(envHome, envConfig);
            txn = env.BeginTransaction();
        }
Esempio n. 7
0
        // Get a cursor in CDS.
        public static void GetCursorInBtreeDBInCDS(
            string home, string name,
            CursorConfig cursorConfig,
            out DatabaseEnvironment env, out BTreeDatabase db,
            out BTreeCursor cursor)
        {
            string dbFileName = name + ".db";

            // Open an environment.
            DatabaseEnvironmentConfig envConfig =
                new DatabaseEnvironmentConfig();
            envConfig.Create = true;
            envConfig.UseCDB = true;
            envConfig.UseMPool = true;
            env = DatabaseEnvironment.Open(home, envConfig);

            /*
             * Open an btree database. The underlying database
             * should be opened with ReadUncommitted if the
             * cursor's isolation degree will be set to be 1.
             */
            BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
            dbConfig.Creation = CreatePolicy.IF_NEEDED;
            dbConfig.Env = env;

            if (cursorConfig.IsolationDegree == Isolation.DEGREE_ONE)
                dbConfig.ReadUncommitted = true;

            db = BTreeDatabase.Open(dbFileName, dbConfig);

            // Get a cursor in the transaction.
            cursor = db.Cursor(cursorConfig);
        }
Esempio n. 8
0
 /// <summary>
 /// Protected constructor
 /// </summary>
 /// <param name="envp">
 /// The environment in which to create this database
 /// </param>
 /// <param name="flags">Flags to pass to the DB->create() method</param>
 protected BaseDatabase(DatabaseEnvironment envp, uint flags) {
     db = new DB(envp == null ? null : envp.dbenv, flags);
     db.api_internal = this;
     if (envp == null) {
         env = new DatabaseEnvironment(db.env());
     } else
         env = envp;
 }
Esempio n. 9
0
        /*
         * Create and open environment and database.
         */
        public static int DBInit(out DatabaseEnvironment env,
            string home, string progName, uint maxLock,
            uint doUnLink)
        {
            DatabaseEnvironmentConfig envConfig;
            LockingConfig lkConfig;

            /* Configure locking subsystem. */
            lkConfig = new LockingConfig();
            lkConfig.MaxLocks = maxLock;

            /* Configure environment. */
            envConfig = new DatabaseEnvironmentConfig();
            envConfig.Create = true;
            envConfig.ErrorPrefix = progName;
            envConfig.LockSystemCfg = lkConfig;
            envConfig.UseLocking = true;

            /*
             * Optionally remove the environment region and
             * open the environment.
             */
            try {
                if (doUnLink == 1)
                    DatabaseEnvironment.Remove(home, true);
                env = DatabaseEnvironment.Open(home, envConfig);
            } catch (Exception e) {
                Console.WriteLine("{0}:{1}\n{2}",
                    e.Source, e.Message, e.StackTrace);
                env = null;
                return EXIT_FAILURE;
            }

            /*
            try
            {
                env = DatabaseEnvironment.Open(home, envConfig);
            }
            catch(Exception e)
            {
                Console.WriteLine("{0}:{1}\n{2}",
                    e.Source, e.Message, e.StackTrace);
                env = null;
                return ExConstants.EXIT_FAILURE;
            }
            */

            return EXIT_SUCCESS;
        }
Esempio n. 10
0
        public void OpenBtreeDBInEnv(string dbName,
		    DatabaseEnvironment env, out BTreeDatabase db,
		    bool create, Transaction txn)
        {
            BTreeDatabaseConfig btreeDBConfig =
                new BTreeDatabaseConfig();
            btreeDBConfig.Env = env;
            if (create == true)
                btreeDBConfig.Creation = CreatePolicy.IF_NEEDED;
            else
                btreeDBConfig.Creation = CreatePolicy.NEVER;
            if (txn == null)
                db = BTreeDatabase.Open(dbName,
                    btreeDBConfig);
            else
                db = BTreeDatabase.Open(dbName,
                    btreeDBConfig, txn);
        }
        public BTreeDatabase Open(DatabaseEnvironment env, bool isMaster)
        {
            string dbName = "rep.db";

            // Set up the database.
            BTreeDatabaseConfig dbCfg = new BTreeDatabaseConfig();
            dbCfg.Env = env;
            if (isMaster)
                dbCfg.Creation = CreatePolicy.IF_NEEDED;

            dbCfg.AutoCommit = true;
            dbCfg.FreeThreaded = true;

            /*
             * Open the database. Do not provide a txn handle. This
             * Open is autocommitted because BTreeDatabaseConfig.AutoCommit
             * is true.
             */
            return BTreeDatabase.Open(dbName, dbCfg);
        }
Esempio n. 12
0
        public void OpenNewSequenceInEnv(string home, string dbname,
		    out DatabaseEnvironment env, out BTreeDatabase db,
		    out Sequence seq)
        {
            DatabaseEnvironmentConfig envConfig =
                new DatabaseEnvironmentConfig();
            envConfig.Create = true;
            envConfig.UseTxns = true;
            envConfig.UseMPool = true;
            envConfig.UseLogging = true;
            env = DatabaseEnvironment.Open(home, envConfig);

            Transaction openTxn = env.BeginTransaction();
            BTreeDatabaseConfig dbConfig =
                new BTreeDatabaseConfig();
            dbConfig.Creation = CreatePolicy.IF_NEEDED;
            dbConfig.Env = env;
            db = BTreeDatabase.Open(dbname + ".db", dbConfig,
                openTxn);
            openTxn.Commit();

            Transaction seqTxn = env.BeginTransaction();
            SequenceConfig seqConfig = new SequenceConfig();
            seqConfig.BackingDatabase = db;
            seqConfig.Creation = CreatePolicy.ALWAYS;
            seqConfig.Decrement = false;
            seqConfig.FreeThreaded = true;
            seqConfig.Increment = true;
            seqConfig.InitialValue = 0;
            seqConfig.key = new DatabaseEntry(
                ASCIIEncoding.ASCII.GetBytes("key"));
            seqConfig.SetRange(Int64.MinValue, Int64.MaxValue);
            seqConfig.Wrap = true;
            seq = new Sequence(seqConfig);
            seqTxn.Commit();
        }
Esempio n. 13
0
        public void MoveWithRMW(string home, string name)
        {
            paramEnv = null;
            paramDB = null;

            // Open the environment.
            DatabaseEnvironmentConfig envCfg =
                new DatabaseEnvironmentConfig();
            envCfg.Create = true;
            envCfg.FreeThreaded = true;
            envCfg.UseLocking = true;
            envCfg.UseLogging = true;
            envCfg.UseMPool = true;
            envCfg.UseTxns = true;
            paramEnv = DatabaseEnvironment.Open(home, envCfg);

            // Open database in transaction.
            Transaction openTxn = paramEnv.BeginTransaction();
            BTreeDatabaseConfig cfg = new BTreeDatabaseConfig();
            cfg.Creation = CreatePolicy.ALWAYS;
            cfg.Env = paramEnv;
            cfg.FreeThreaded = true;
            cfg.PageSize = 4096;
            cfg.Duplicates = DuplicatesPolicy.UNSORTED;
            paramDB = BTreeDatabase.Open(name + ".db", cfg, openTxn);
            openTxn.Commit();

            /*
             * Put 10 different, 2 duplicate and another different
             * records into database.
             */
            Transaction txn = paramEnv.BeginTransaction();
            for (int i = 0; i < 13; i++)
            {
                DatabaseEntry key, data;
                if (i == 10 || i == 11)
                {
                    key = new DatabaseEntry(
                        ASCIIEncoding.ASCII.GetBytes("key"));
                    data = new DatabaseEntry(
                        ASCIIEncoding.ASCII.GetBytes("data"));
                }
                else
                {
                    key = new DatabaseEntry(
                        BitConverter.GetBytes(i));
                    data = new DatabaseEntry(
                        BitConverter.GetBytes(i));
                }
                paramDB.Put(key, data, txn);
            }

            txn.Commit();

            // Get a event wait handle.
            signal = new EventWaitHandle(false, EventResetMode.ManualReset);

            /*
             * Start RdMfWt() in two threads. RdMfWt() reads
             * and writes data into database.
             */
            Thread t1 = new Thread(new ThreadStart(RdMfWt));
            Thread t2 = new Thread(new ThreadStart(RdMfWt));
            t1.Start();
            t2.Start();

            /*
             * Give both threads time to read before signalling
             * them to write.
             */
            Thread.Sleep(1000);

            // Invoke the write operation in both threads.
            signal.Set();

            // Return the number of deadlocks.
            while (t1.IsAlive || t2.IsAlive)
            {
                /*
                 * Give both threads time to write before
                 * counting the number of deadlocks.
                 */
                Thread.Sleep(1000);
                uint deadlocks = paramEnv.DetectDeadlocks(
                   DeadlockPolicy.DEFAULT);

                // Confirm that there won't be any deadlock.
                Assert.AreEqual(0, deadlocks);
            }

            t1.Join();
            t2.Join();
            paramDB.Close();
            paramEnv.Close();
        }
Esempio n. 14
0
        /*
         * Configure a transactional cursor to have degree 1
         * isolation. The cursor's read operations could return
         * modified but not yet commited data.
         */
        public void CursorReadUncommited(
		    DatabaseEnvironment env, BTreeDatabase db,
		    Cursor cursor, Transaction txn)
        {
            Console.WriteLine("CursorReadUncommited");
        }
Esempio n. 15
0
        public void TestSnapshotIsolation()
        {
            BTreeDatabaseConfig dbConfig;
            DatabaseEntry key, data;
            DatabaseEnvironmentConfig envConfig;
            Thread readThread, updateThread;
            Transaction txn;

            updateTxn = null;
            readTxn = null;
            paramDB = null;
            paramEnv = null;
            testName = "TestSnapshotIsolation";
            testHome = testFixtureHome + "/" + testName;

            Configuration.ClearDir(testHome);

            /*
             * Open environment with DB_MULTIVERSION
             * which is required by DB_TXN_SNAPSHOT.
             */
            envConfig = new DatabaseEnvironmentConfig();
            envConfig.Create = true;
            envConfig.UseMVCC = true;
            envConfig.UseTxns = true;
            envConfig.UseMPool = true;
            envConfig.UseLocking = true;
            envConfig.TxnTimeout = 1000;
            paramEnv = DatabaseEnvironment.Open(
                testHome, envConfig);
            paramEnv.DetectDeadlocks(DeadlockPolicy.YOUNGEST);

            /*
             * Open a transactional database and put 1000 records
             * into it within transaction.
             */
            txn = paramEnv.BeginTransaction();
            dbConfig = new BTreeDatabaseConfig();
            dbConfig.Creation = CreatePolicy.IF_NEEDED;
            dbConfig.UseMVCC = true;
            dbConfig.Env = paramEnv;
            paramDB = BTreeDatabase.Open(
                testName + ".db", dbConfig, txn);
            for (int i = 0; i < 256; i++)
            {
                key = new DatabaseEntry(
                    BitConverter.GetBytes(i));
                data = new DatabaseEntry(
                    BitConverter.GetBytes(i));
                paramDB.Put(key, data, txn);
            }
            txn.Commit();

            /*
             * Begin two threads, read and update thread.
             * The update thread runs a update transaction
             * using full read/write locking. The read thread
             * set DB_TXN_SNAPSHOT on read-only cursor.
             */
            readThread = new Thread(new ThreadStart(ReadTxn));
            updateThread = new Thread(new ThreadStart(UpdateTxn));
            updateThread.Start();
            Thread.Sleep(1000);
            readThread.Start();
            readThread.Join();
            updateThread.Join();

            // Commit transacion in both two threads.
            if (updateTxn != null)
                updateTxn.Commit();
            if (readTxn != null)
                readTxn.Commit();

            /*
             * Confirm that the overwrite operation works.
             */
            ConfirmOverwrite();

            paramDB.Close();
            paramEnv.Close();
        }
Esempio n. 16
0
        private void Open()
        {
            Console.WriteLine("Opening environment and database");

            // Set up the environment.
            DatabaseEnvironmentConfig envCfg = new DatabaseEnvironmentConfig();
            envCfg.Create = true;
            envCfg.UseMPool = true;
            envCfg.UseLocking = true;
            envCfg.UseLogging = true;
            envCfg.UseTxns = true;

            // Allow multiple threads visit to the environment handle.
            envCfg.FreeThreaded = true;

            if (inMem)
                envCfg.Private = true;
            else
                envCfg.RunRecovery = true;

            /*
             * Indicate that we want db to internally perform
             * deadlock detection, aborting the transaction that
             * has performed the least amount of WriteData activity
             * in the event of a deadlock.
             */
            envCfg.LockSystemCfg = new LockingConfig();
            envCfg.LockSystemCfg.DeadlockResolution =
                DeadlockPolicy.MIN_WRITE;

            if (inMem) {
                // Specify in-memory logging.
                envCfg.LogSystemCfg = new LogConfig();
                envCfg.LogSystemCfg.InMemory = true;

                /*
                 * Specify the size of the in-memory log buffer
                 * Must be large enough to handle the log data
                 * created by the largest transaction.
                 */
                envCfg.LogSystemCfg.BufferSize = 10 * 1024 * 1024;

                /*
                 * Specify the size of the in-memory cache,
                 * large enough to avoid paging to disk.
                 */
                envCfg.MPoolSystemCfg = new MPoolConfig();
                envCfg.MPoolSystemCfg.CacheSize =
                    new CacheInfo(0, 10 * 1024 * 1024, 1);
            }

            // Set up the database.
            BTreeDatabaseConfig dbCfg = new BTreeDatabaseConfig();
            dbCfg.AutoCommit = true;
            dbCfg.Creation = CreatePolicy.IF_NEEDED;
            dbCfg.Duplicates = DuplicatesPolicy.SORTED;
            dbCfg.FreeThreaded = true;
            dbCfg.ReadUncommitted = true;

            /*
                         * Open the environment. Any errors will be caught
                         * by the caller.
                         */
            env = DatabaseEnvironment.Open(home, envCfg);

            /*
             * Open the database. Do not provide a txn handle. This
             * Open is autocommitted because BTreeDatabaseConfig.AutoCommit
             * is true.
             */
            dbCfg.Env = env;
            db = BTreeDatabase.Open(dbName, dbCfg);
        }
Esempio n. 17
0
        public void PutRecordWithTxn(out DatabaseEnvironment env,
		    string home, string dbName, out Transaction txn)
        {
            BTreeDatabase db;

            // Open a new environment and begin a transaction.
            SetUpTransactionalEnv(home, out env);
            TransactionConfig txnConfig = new TransactionConfig();
            txnConfig.Name = "Transaction";
            txn = env.BeginTransaction(txnConfig);
            Assert.AreEqual("Transaction", txn.Name);

            // Open a new database within the transaction.
            OpenBtreeDBInEnv(dbName + ".db", env, out db, true, txn);

            // Write to the database within the transaction.
            WriteOneIntoBtreeDBWithTxn(db, txn);

            // Close the database.
            db.Close();
        }
Esempio n. 18
0
 /// <summary>
 /// Protected constructor
 /// </summary>
 /// <param name="env">
 /// The environment in which to create this database
 /// </param>
 /// <param name="flags">Flags to pass to the DB->create() method</param>
 protected Database(DatabaseEnvironment env, uint flags)
     : base(env, flags)
 {
 }
Esempio n. 19
0
        public void WriteRecordsInTxn(BTreeDatabase db, 
		    DatabaseEnvironment env)
        {
            Transaction txn = env.BeginTransaction();
            /*
             * Write ten records into the database. The records
             * from 1st to 5th and 8th to 10th are unique in the
             * database. The data in the 6th and 7th records
             * are the same.
             */
            for (int i = 0; i < 10; i++)
            {
                if (i == 5 || i == 6)
                    db.Put(new DatabaseEntry(
                        BitConverter.GetBytes(i)),
                        new DatabaseEntry(
                        BitConverter.GetBytes((int)10)), txn);
                else
                    db.Put(new DatabaseEntry(
                        BitConverter.GetBytes(i)),
                        new DatabaseEntry(BitConverter.GetBytes(i)), txn);
            }

            txn.Commit();
        }
Esempio n. 20
0
        public void PanicPreparedTxn(string home, string dbName,
		    out DatabaseEnvironment env, out byte[] globalID)
        {
            Transaction txn;

            // Put record into database within transaction.
            PutRecordWithTxn(out env, home, dbName, out txn);

            /*
             * Generate global ID for the transaction. Copy
             * transaction ID to the first 4 tyes in global ID.
             */
            globalID = new byte[Transaction.GlobalIdLength];
            byte[] txnID = new byte[4];
            txnID = BitConverter.GetBytes(txn.Id);
            for (int i = 0; i < txnID.Length; i++)
                globalID[i] = txnID[i];

            // Prepare the transaction.
            txn.Prepare(globalID);

            // Panic the environment.
            env.Panic();
        }
Esempio n. 21
0
        public static void GetCursorInBtreeDBInTDS(
		    string home, string name,
		    CursorConfig cursorConfig,
		    out DatabaseEnvironment env, out BTreeDatabase db,
		    out BTreeCursor cursor, out Transaction txn)
        {
            string dbFileName = name + ".db";

            Configuration.ClearDir(home);

            // Open an environment.
            DatabaseEnvironmentConfig envConfig =
                new DatabaseEnvironmentConfig();
            envConfig.Create = true;
            envConfig.UseMPool = true;
            envConfig.UseTxns = true;
            envConfig.NoMMap = false;
            envConfig.UseLocking = true;
            env = DatabaseEnvironment.Open(home, envConfig);

            // Begin a transaction.
            txn = env.BeginTransaction();

            /*
             * Open an btree database. The underlying database
             * should be opened with ReadUncommitted if the
             * cursor's isolation degree will be set to be 1.
             */
            BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
            dbConfig.Creation = CreatePolicy.IF_NEEDED;
            dbConfig.Env = env;
            if (cursorConfig != null &&
                cursorConfig.IsolationDegree == Isolation.DEGREE_ONE)
                dbConfig.ReadUncommitted = true;

            db = BTreeDatabase.Open(dbFileName, dbConfig, txn);

            // Get a cursor in the transaction.
            if (cursorConfig != null)
                cursor = db.Cursor(cursorConfig, txn);
            else
                cursor = db.Cursor(txn);
        }
Esempio n. 22
0
        /*
         * ifSetLock is used to indicate which timeout function
         * is used, SetLockTimeout or SetTxnTimeout.
         */
        public void TestTimeOut(bool ifSetLock)
        {
            // Open environment and begin transaction.
            Transaction txn;
            deadLockEnv = null;
            SetUpEnvWithTxnAndLocking(testHome,
                out deadLockEnv, out txn, 0, 0, 0, 0);

            // Define deadlock detection and resolve policy.
            deadLockEnv.DeadlockResolution =
                DeadlockPolicy.YOUNGEST;
            if (ifSetLock == true)
                txn.SetLockTimeout(10);
            else
                txn.SetTxnTimeout(10);

            txn.Commit();
            deadLockEnv.Close();
        }
Esempio n. 23
0
        public void SetUpTransactionalEnv(string home, 
		    out DatabaseEnvironment env)
        {
            DatabaseEnvironmentConfig envConfig =
                new DatabaseEnvironmentConfig();
            envConfig.Create = true;
            envConfig.UseLogging = true;
            envConfig.UseMPool = true;
            envConfig.UseTxns = true;
            env = DatabaseEnvironment.Open(
                home, envConfig);
        }
Esempio n. 24
0
 private HeapDatabase(DatabaseEnvironment env, uint flags)
     : base(env, flags)
 {
 }
 /// <summary>
 /// Instantiate a new DatabaseConfig object
 /// </summary>
 public DatabaseConfig()
 {
     Env = null;
     Priority = CachePriority.DEFAULT;
     pagesizeIsSet = false;
     encryptionIsSet = false;
     ErrorPrefix = null;
     Feedback = null;
     DoChecksum = false;
     NonDurableTxns = false;
     AutoCommit = false;
     FreeThreaded = false;
     NoMMap = false;
     ReadOnly = false;
     ReadUncommitted = false;
     Truncate = false;
     UseMVCC = false;
 }
 internal SecondaryRecnoDatabase(DatabaseEnvironment env, uint flags)
     : base(env, flags)
 {
 }
Esempio n. 27
0
 internal Mutex(DatabaseEnvironment owner, uint mutexValue)
 {
     env = owner;
     val = mutexValue;
 }
Esempio n. 28
0
        public void OpenSecDBInTxn(string home, string dbFileName, 
		    string dbSecFileName, out DatabaseEnvironment env,
		    out BTreeDatabase db, out SecondaryBTreeDatabase secDB)
        {
            // Open environment.
            DatabaseEnvironmentConfig envCfg =
                new DatabaseEnvironmentConfig();
            envCfg.Create = true;
            envCfg.UseLocking = true;
            envCfg.UseLogging = true;
            envCfg.UseMPool = true;
            envCfg.UseTxns = true;
            env = DatabaseEnvironment.Open(
                home, envCfg);

            // Open primary and secondary database in a transaction.
            Transaction openTxn = env.BeginTransaction();
            BTreeDatabaseConfig dbConfig =
                new BTreeDatabaseConfig();
            dbConfig.Creation = CreatePolicy.IF_NEEDED;
            dbConfig.Env = env;
            dbConfig.PageSize = 4096;
            dbConfig.Duplicates = DuplicatesPolicy.NONE;
            dbConfig.ReadUncommitted = true;
            db = BTreeDatabase.Open(dbFileName, dbConfig,
                openTxn);
            openTxn.Commit();

            openTxn = env.BeginTransaction();
            SecondaryBTreeDatabaseConfig secConfig =
                new SecondaryBTreeDatabaseConfig(db,
                new SecondaryKeyGenDelegate(SecondaryKeyGen));
            secConfig.Creation = CreatePolicy.IF_NEEDED;
            secConfig.Duplicates = DuplicatesPolicy.SORTED;
            secConfig.Env = env;
            secConfig.ReadUncommitted = true;
            secDB = SecondaryBTreeDatabase.Open(dbSecFileName,
                secConfig, openTxn);
            openTxn.Commit();
        }
Esempio n. 29
0
 private RecnoDatabase(DatabaseEnvironment env, uint flags)
     : base(env, flags)
 {
 }
Esempio n. 30
0
 /// <summary>
 /// Protected construtor
 /// </summary>
 /// <param name="env">The environment in which to open the DB</param>
 /// <param name="flags">Flags to pass to DB->create</param>
 protected SecondaryDatabase(DatabaseEnvironment env, uint flags)
     : base(env, flags) { }
Esempio n. 31
0
 private BTreeDatabase(DatabaseEnvironment env, uint flags)
     : base(env, flags)
 {
 }