当前位置: 首页>>代码示例>>C#>>正文


C# BerkeleyDB.SecondaryBTreeDatabaseConfig类代码示例

本文整理汇总了C#中BerkeleyDB.SecondaryBTreeDatabaseConfig的典型用法代码示例。如果您正苦于以下问题:C# SecondaryBTreeDatabaseConfig类的具体用法?C# SecondaryBTreeDatabaseConfig怎么用?C# SecondaryBTreeDatabaseConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SecondaryBTreeDatabaseConfig类属于BerkeleyDB命名空间,在下文中一共展示了SecondaryBTreeDatabaseConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Config

        public static void Config(XmlElement xmlElement,
		    ref SecondaryBTreeDatabaseConfig secBtreeDBConfig,
		    bool compulsory)
        {
            uint minKeysPerPage = new uint();

            SecondaryDatabaseConfig secDBConfig = secBtreeDBConfig;
            SecondaryDatabaseConfigTest.Config(xmlElement,
                ref secDBConfig, compulsory);

            // Configure specific fields/properties of Btree db
            Configuration.ConfigCreatePolicy(xmlElement,
                "Creation", ref secBtreeDBConfig.Creation, compulsory);
            Configuration.ConfigDuplicatesPolicy(xmlElement,
                "Duplicates", ref secBtreeDBConfig.Duplicates,
                compulsory);
            if (Configuration.ConfigUint(xmlElement,
                "MinKeysPerPage", ref minKeysPerPage, compulsory))
                secBtreeDBConfig.MinKeysPerPage = minKeysPerPage;
            Configuration.ConfigBool(xmlElement,
                "NoReverseSplitting",
                ref secBtreeDBConfig.NoReverseSplitting, compulsory);
            Configuration.ConfigBool(xmlElement,
                "UseRecordNumbers",
                ref secBtreeDBConfig.UseRecordNumbers, compulsory);
        }
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:26,代码来源:SecondaryBTreeDatabaseConfigTest.cs

示例2: GetSecCursor

        public void GetSecCursor(BTreeDatabase db,
		    string secFileName, SecondaryKeyGenDelegate keyGen,
		    out SecondaryBTreeDatabase secDB,
		    out SecondaryCursor cursor, bool ifCfg,
		    DatabaseEntry data)
        {
            // Open secondary database.
            SecondaryBTreeDatabaseConfig secCfg =
                new SecondaryBTreeDatabaseConfig(db, keyGen);
            secCfg.Creation = CreatePolicy.IF_NEEDED;
            secCfg.Duplicates = DuplicatesPolicy.SORTED;
            secDB = SecondaryBTreeDatabase.Open(secFileName, secCfg);

            int[] intArray = new int[4];
            intArray[0] = 0;
            intArray[1] = 1;
            intArray[2] = 2049;
            intArray[3] = 65537;
            for (int i = 0; i < 4; i++)
            {
                DatabaseEntry record = new DatabaseEntry(
                    BitConverter.GetBytes(intArray[i]));
                db.Put(record, record);
            }

            // Get secondary cursor on the secondary database.
            if (ifCfg == false)
                cursor = secDB.SecondaryCursor();
            else
                cursor = secDB.SecondaryCursor(new CursorConfig());

            // Position the cursor.
            if (data != null)
                Assert.IsTrue(cursor.Move(data, true));
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:35,代码来源:JoinCursorTest.cs

示例3: Config

 private void Config(SecondaryBTreeDatabaseConfig cfg) {
     base.Config((SecondaryDatabaseConfig)cfg);
     db.set_flags(cfg.flags);
     if (cfg.Compare != null)
         Compare = cfg.Compare;
     if (cfg.PrefixCompare != null)
         PrefixCompare = cfg.PrefixCompare;
     if (cfg.DuplicateCompare != null)
         DupCompare = cfg.DuplicateCompare;
     if (cfg.minkeysIsSet)
         db.set_bt_minkey(cfg.MinKeysPerPage);
 }
开发者ID:rohitlodha,项目名称:DenverDB,代码行数:12,代码来源:SecondaryBTreeDatabase.cs

示例4: GetSecondaryCursurWithTxn

        public void GetSecondaryCursurWithTxn(string home,
		    string name, bool ifCfg)
        {
            string dbFileName = name + ".db";
            SecondaryCursor cursor;

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

            // Open primary/secondary database.
            Transaction txn = env.BeginTransaction();
            BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
            dbConfig.Creation = CreatePolicy.IF_NEEDED;
            dbConfig.Env = env;
            BTreeDatabase db = BTreeDatabase.Open(dbFileName,
                dbConfig, txn);

            SecondaryBTreeDatabaseConfig secDBConfig = new
                SecondaryBTreeDatabaseConfig(db,
                new SecondaryKeyGenDelegate(SecondaryKeyGen));
            secDBConfig.Env = env;
            SecondaryBTreeDatabase secDB =
                SecondaryBTreeDatabase.Open(dbFileName,
                secDBConfig, txn);

            for (int i = 0; i < 10; i++)
                db.Put(new DatabaseEntry(BitConverter.GetBytes(i)),
                    new DatabaseEntry(BitConverter.GetBytes((int)i)), txn);

            // Create secondary cursor.
            if (ifCfg == false)
                secDB.SecondaryCursor(txn);
            else if (ifCfg == true)
            {
                CursorConfig cursorConfig = new CursorConfig();
                cursorConfig.WriteCursor = false;
                cursor = secDB.SecondaryCursor(cursorConfig, txn);
                cursor.Close();
            }

            secDB.Close();
            db.Close();
            txn.Commit();
            env.Close();
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:51,代码来源:SecondaryDatabaseTest.cs

示例5: TestCompare

        public void TestCompare()
        {
            testName = "TestCompare";
            SetUpTest(true);
            string dbFileName = testHome + "/" + testName + ".db";

            // Open a primary btree database.
            BTreeDatabaseConfig btreeDBConfig =
                new BTreeDatabaseConfig();
            btreeDBConfig.Creation = CreatePolicy.ALWAYS;
            BTreeDatabase btreeDB = BTreeDatabase.Open(
                dbFileName, btreeDBConfig);

            // Open a secondary btree database.
            SecondaryBTreeDatabaseConfig secBtreeDBConfig =
                new SecondaryBTreeDatabaseConfig(null, null);
            secBtreeDBConfig.Primary = btreeDB;
            secBtreeDBConfig.Compare =
                new EntryComparisonDelegate(
                SecondaryEntryComparison);
            secBtreeDBConfig.KeyGen =
                new SecondaryKeyGenDelegate(SecondaryKeyGen);
            SecondaryBTreeDatabase secDB =
                SecondaryBTreeDatabase.Open(
                dbFileName, secBtreeDBConfig);

            /*
             * Get the compare function set in the configuration
             * and run it in a comparison to see if it is alright.
             */
            EntryComparisonDelegate cmp =
                secDB.Compare;
            DatabaseEntry dbt1, dbt2;
            dbt1 = new DatabaseEntry(
                BitConverter.GetBytes((int)257));
            dbt2 = new DatabaseEntry(
                BitConverter.GetBytes((int)255));
            Assert.Less(0, cmp(dbt1, dbt2));

            for (int i = 0; i < 1000; i++)
                btreeDB.Put(new DatabaseEntry(
                    BitConverter.GetBytes(i)), new DatabaseEntry(
                    BitConverter.GetBytes(i)));

            secDB.Close();
            btreeDB.Close();
        }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:47,代码来源:SecondaryBTreeDatabaseTest.cs

示例6: Confirm

        public static void Confirm(XmlElement xmlElement,
		    SecondaryBTreeDatabaseConfig secBtreeDBConfig,
		    bool compulsory)
        {
            SecondaryDatabaseConfig secDBConfig =
                secBtreeDBConfig;
            SecondaryDatabaseConfigTest.Confirm(xmlElement,
                secDBConfig, compulsory);

            // Confirm secondary btree database specific configuration.
            Configuration.ConfirmCreatePolicy(xmlElement,
                "Creation", secBtreeDBConfig.Creation, compulsory);
            Configuration.ConfirmDuplicatesPolicy(xmlElement,
                "Duplicates", secBtreeDBConfig.Duplicates, compulsory);
            Configuration.ConfirmUint(xmlElement, "MinKeysPerPage",
                secBtreeDBConfig.MinKeysPerPage, compulsory);
            Configuration.ConfirmBool(xmlElement,
                "NoReverseSplitting",
                secBtreeDBConfig.NoReverseSplitting, compulsory);
            Configuration.ConfirmBool(xmlElement,
                "UseRecordNumbers",
                secBtreeDBConfig.UseRecordNumbers,
                compulsory);
        }
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:24,代码来源:SecondaryBTreeDatabaseConfigTest.cs

示例7: OpenSecDBInTxn

        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();
        }
开发者ID:mcandre,项目名称:db,代码行数:40,代码来源:SecondaryCursorTest.cs

示例8: OpenSecDB

        public void OpenSecDB(string dbFileName, 
		    string dbSecFileName, out BTreeDatabase db,
		    out SecondaryBTreeDatabase secDB)
        {
            // Open a primary database.
            BTreeDatabaseConfig dbConfig =
                new BTreeDatabaseConfig();
            dbConfig.Creation = CreatePolicy.IF_NEEDED;
            db = BTreeDatabase.Open(dbFileName, dbConfig);

            // Open a secondary database.
            SecondaryBTreeDatabaseConfig secConfig =
                new SecondaryBTreeDatabaseConfig(db,
                new SecondaryKeyGenDelegate(SecondaryKeyGen));
            secConfig.Creation = CreatePolicy.IF_NEEDED;
            secConfig.Duplicates = DuplicatesPolicy.SORTED;
            secDB = SecondaryBTreeDatabase.Open(dbSecFileName,
                secConfig);
        }
开发者ID:mcandre,项目名称:db,代码行数:19,代码来源:SecondaryCursorTest.cs

示例9: TestForeignKeyDelete

        public void TestForeignKeyDelete(DatabaseType dbtype, ForeignKeyDeleteAction action)
        {
            SetUpTest(true);
            string dbFileName = testHome + "/" + testName + ".db";
            string fdbFileName = testHome + "/" + testName + "foreign.db";
            string sdbFileName = testHome + "/" + testName + "sec.db";

            Database primaryDB, fdb;
            SecondaryDatabase secDB;

            // Open primary database.
            if (dbtype == DatabaseType.BTREE) {
                BTreeDatabaseConfig btConfig = new BTreeDatabaseConfig();
                btConfig.Creation = CreatePolicy.ALWAYS;
                primaryDB = BTreeDatabase.Open(dbFileName, btConfig);
                fdb = BTreeDatabase.Open(fdbFileName, btConfig);
            } else if (dbtype == DatabaseType.HASH) {
                HashDatabaseConfig hConfig = new HashDatabaseConfig();
                hConfig.Creation = CreatePolicy.ALWAYS;
                primaryDB = HashDatabase.Open(dbFileName, hConfig);
                fdb = HashDatabase.Open(fdbFileName, hConfig);
            } else if (dbtype == DatabaseType.QUEUE) {
                QueueDatabaseConfig qConfig = new QueueDatabaseConfig();
                qConfig.Creation = CreatePolicy.ALWAYS;
                qConfig.Length = 4;
                primaryDB = QueueDatabase.Open(dbFileName, qConfig);
                fdb = QueueDatabase.Open(fdbFileName, qConfig);
            } else if (dbtype == DatabaseType.RECNO) {
                RecnoDatabaseConfig rConfig = new RecnoDatabaseConfig();
                rConfig.Creation = CreatePolicy.ALWAYS;
                primaryDB = RecnoDatabase.Open(dbFileName, rConfig);
                fdb = RecnoDatabase.Open(fdbFileName, rConfig);
            } else {
                throw new ArgumentException("Invalid DatabaseType");
            }

            // Open secondary database.
            if (dbtype == DatabaseType.BTREE) {
                SecondaryBTreeDatabaseConfig secbtConfig =
                    new SecondaryBTreeDatabaseConfig(primaryDB,
                    new SecondaryKeyGenDelegate(SecondaryKeyGen));
                secbtConfig.Creation = CreatePolicy.ALWAYS;
                secbtConfig.Duplicates = DuplicatesPolicy.SORTED;
                if (action == ForeignKeyDeleteAction.NULLIFY)
                    secbtConfig.SetForeignKeyConstraint(fdb, action, new ForeignKeyNullifyDelegate(Nullify));
                else
                    secbtConfig.SetForeignKeyConstraint(fdb, action);
                secDB = SecondaryBTreeDatabase.Open(sdbFileName, secbtConfig);
            } else if (dbtype == DatabaseType.HASH) {
                SecondaryHashDatabaseConfig sechConfig =
                    new SecondaryHashDatabaseConfig(primaryDB,
                    new SecondaryKeyGenDelegate(SecondaryKeyGen));
                sechConfig.Creation = CreatePolicy.ALWAYS;
                sechConfig.Duplicates = DuplicatesPolicy.SORTED;
                if (action == ForeignKeyDeleteAction.NULLIFY)
                    sechConfig.SetForeignKeyConstraint(fdb, action, new ForeignKeyNullifyDelegate(Nullify));
                else
                    sechConfig.SetForeignKeyConstraint(fdb, action);
                secDB = SecondaryHashDatabase.Open(sdbFileName, sechConfig);
            } else if (dbtype == DatabaseType.QUEUE) {
                SecondaryQueueDatabaseConfig secqConfig =
                    new SecondaryQueueDatabaseConfig(primaryDB,
                    new SecondaryKeyGenDelegate(SecondaryKeyGen));
                secqConfig.Creation = CreatePolicy.ALWAYS;
                secqConfig.Length = 4;
                if (action == ForeignKeyDeleteAction.NULLIFY)
                    secqConfig.SetForeignKeyConstraint(fdb, action, new ForeignKeyNullifyDelegate(Nullify));
                else
                    secqConfig.SetForeignKeyConstraint(fdb, action);
                secDB = SecondaryQueueDatabase.Open(sdbFileName, secqConfig);
            } else if (dbtype == DatabaseType.RECNO) {
                SecondaryRecnoDatabaseConfig secrConfig =
                    new SecondaryRecnoDatabaseConfig(primaryDB,
                    new SecondaryKeyGenDelegate(SecondaryKeyGen));
                secrConfig.Creation = CreatePolicy.ALWAYS;
                if (action == ForeignKeyDeleteAction.NULLIFY)
                    secrConfig.SetForeignKeyConstraint(fdb, action, new ForeignKeyNullifyDelegate(Nullify));
                else
                    secrConfig.SetForeignKeyConstraint(fdb, action);
                secDB = SecondaryRecnoDatabase.Open(sdbFileName, secrConfig);
            } else {
                throw new ArgumentException("Invalid DatabaseType");
            }

            /* Use integer keys for Queue/Recno support. */
            fdb.Put(new DatabaseEntry(BitConverter.GetBytes(100)),
                new DatabaseEntry(BitConverter.GetBytes(1001)));
            fdb.Put(new DatabaseEntry(BitConverter.GetBytes(200)),
                new DatabaseEntry(BitConverter.GetBytes(2002)));
            fdb.Put(new DatabaseEntry(BitConverter.GetBytes(300)),
                new DatabaseEntry(BitConverter.GetBytes(3003)));

            primaryDB.Put(new DatabaseEntry(BitConverter.GetBytes(1)),
                new DatabaseEntry(BitConverter.GetBytes(100)));
            primaryDB.Put(new DatabaseEntry(BitConverter.GetBytes(2)),
                new DatabaseEntry(BitConverter.GetBytes(200)));
            if (dbtype == DatabaseType.BTREE || dbtype == DatabaseType.HASH)
                primaryDB.Put(new DatabaseEntry(BitConverter.GetBytes(3)),
                    new DatabaseEntry(BitConverter.GetBytes(100)));

//.........这里部分代码省略.........
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:101,代码来源:ForeignKeyTest.cs

示例10: Open

        /// <summary>
        /// Instantiate a new SecondaryBTreeDatabase object, open the
        /// database represented by <paramref name="Filename"/> and associate 
        /// the database with the
        /// <see cref="SecondaryDatabaseConfig.Primary">primary index</see>.
        /// </summary>
        /// <remarks>
        /// <para>
        /// If both <paramref name="Filename"/> and
        /// <paramref name="DatabaseName"/> are null, the database is strictly
        /// temporary and cannot be opened by any other thread of control, thus
        /// the database can only be accessed by sharing the single database 
        /// object that created it, in circumstances where doing so is safe. If
        /// <paramref name="Filename"/> is null and
        /// <paramref name="DatabaseName"/> is non-null, the database can be
        /// opened by other threads of control and will be replicated to client
        /// sites in any replication group.
        /// </para>
        /// <para>
        /// If <paramref name="txn"/> is null, but
        /// <see cref="DatabaseConfig.AutoCommit"/> is set, the operation will
        /// be implicitly transaction protected. Note that transactionally
        /// protected operations on a datbase object requires the object itself
        /// be transactionally protected during its open. Also note that the
        /// transaction must be committed before the object is closed.
        /// </para>
        /// </remarks>
        /// <param name="Filename">
        /// The name of an underlying file that will be used to back the
        /// database. In-memory databases never intended to be preserved on disk
        /// may be created by setting this parameter to null.
        /// </param>
        /// <param name="DatabaseName">
        /// This parameter allows applications to have multiple databases in a
        /// single file. Although no DatabaseName needs to be specified, it is
        /// an error to attempt to open a second database in a file that was not
        /// initially created using a database name.
        /// </param>
        /// <param name="cfg">The database's configuration</param>
        /// <param name="txn">
        /// If the operation is part of an application-specified transaction,
        /// <paramref name="txn"/> is a Transaction object returned from
        /// <see cref="DatabaseEnvironment.BeginTransaction"/>; if
        /// the operation is part of a Berkeley DB Concurrent Data Store group,
        /// <paramref name="txn"/> is a handle returned from
        /// <see cref="DatabaseEnvironment.BeginCDSGroup"/>; otherwise null.
        /// </param>
        /// <returns>A new, open database object</returns>
        public static SecondaryBTreeDatabase Open(
            string Filename, string DatabaseName,
            SecondaryBTreeDatabaseConfig cfg, Transaction txn)
        {
            SecondaryBTreeDatabase ret = new SecondaryBTreeDatabase(cfg.Env, 0);
            ret.Config(cfg);
            ret.db.open(Transaction.getDB_TXN(txn), Filename,
                DatabaseName, cfg.DbType.getDBTYPE(), cfg.openFlags, 0);
            ret.isOpen = true;
            ret.doAssocRef = new BDB_AssociateDelegate(
                SecondaryDatabase.doAssociate);
            cfg.Primary.db.associate(Transaction.getDB_TXN(txn),
                ret.db, ret.doAssocRef, cfg.assocFlags);

            if (cfg.ForeignKeyDatabase != null) {
                if (cfg.OnForeignKeyDelete == ForeignKeyDeleteAction.NULLIFY)
                    ret.doNullifyRef =
                        new BDB_AssociateForeignDelegate(doNullify);
                else
                    ret.doNullifyRef = null;
                cfg.ForeignKeyDatabase.db.associate_foreign(
                    ret.db, ret.doNullifyRef, cfg.foreignFlags);
            }
            return ret;
        }
开发者ID:hyc,项目名称:BerkeleyDB,代码行数:73,代码来源:SecondaryBTreeDatabase.cs

示例11: OpenSecQueueDB

        public void OpenSecQueueDB(string dbFileName, 
		    string dbSecFileName, bool ifDBName)
        {
            // Open a primary btree database.
            BTreeDatabaseConfig primaryDBConfig =
                new BTreeDatabaseConfig();
            primaryDBConfig.Creation = CreatePolicy.IF_NEEDED;
            BTreeDatabase primaryDB;

            /*
             * If secondary database name is given, the primary
             * database is also opened with database name.
             */
            if (ifDBName == false)
                primaryDB = BTreeDatabase.Open(dbFileName,
                    primaryDBConfig);
            else
                primaryDB = BTreeDatabase.Open(dbFileName,
                    "primary", primaryDBConfig);

            try
            {
                // Open a new secondary database.
                SecondaryBTreeDatabaseConfig secBTDBConfig =
                    new SecondaryBTreeDatabaseConfig(
                    primaryDB, null);
                secBTDBConfig.Creation =
                    CreatePolicy.IF_NEEDED;

                SecondaryBTreeDatabase secBTDB;
                if (ifDBName == false)
                    secBTDB = SecondaryBTreeDatabase.Open(
                        dbSecFileName, secBTDBConfig);
                else
                    secBTDB = SecondaryBTreeDatabase.Open(
                        dbSecFileName, "secondary",
                        secBTDBConfig);

                // Close the secondary database.
                secBTDB.Close();

                // Open the existing secondary database.
                SecondaryDatabaseConfig secDBConfig =
                    new SecondaryDatabaseConfig(
                    primaryDB, null);

                SecondaryDatabase secDB;
                if (ifDBName == false)
                    secDB = SecondaryBTreeDatabase.Open(
                        dbSecFileName, secDBConfig);
                else
                    secDB = SecondaryBTreeDatabase.Open(
                        dbSecFileName, "secondary", secDBConfig);

                // Close secondary database.
                secDB.Close();
            }
            catch (DatabaseException)
            {
                throw new TestException();
            }
            finally
            {
                // Close primary database.
                primaryDB.Close();
            }
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:67,代码来源:SecondaryDatabaseTest.cs

示例12: MyDbs

        public MyDbs(string databaseHome)
        {
            vDbName = "vendordb.db";
            iDbName = "inventorydb.db";
            itemSDbName = "itemname.sdb";

            if (databaseHome != null) {
                vDbName = databaseHome + "\\" + vDbName;
                iDbName = databaseHome + "\\" + iDbName;
                itemSDbName = databaseHome + "\\" + itemSDbName;
            }

            btreeConfig = new BTreeDatabaseConfig();
            btreeConfig.Creation = CreatePolicy.IF_NEEDED;
            btreeConfig.CacheSize = new CacheInfo(0, 64 * 1024, 1);
            btreeConfig.ErrorPrefix = "excs_getting_started";
            btreeConfig.PageSize = 8 * 1024;

            /* Optionally remove existing database files. */
            try {
                RemoveDbFile(vDbName);
                RemoveDbFile(iDbName);
                RemoveDbFile(itemSDbName);
            } catch (Exception e) {
                Console.WriteLine("Error deleting db.");
                Console.WriteLine(e.Message);
                throw e;
            }

            /* Create and open the Inventory and Vendor database files. */
            try {
                vbtreeDB = BTreeDatabase.Open(vDbName, btreeConfig);
            } catch (Exception e) {
                Console.WriteLine("Error opening {0}.", vDbName);
                Console.WriteLine(e.Message);
                throw e;
            }

            try {
                ibtreeDB = BTreeDatabase.Open(iDbName, btreeConfig);
            } catch (Exception e) {
                Console.WriteLine("Error opening {0}.", iDbName);
                Console.WriteLine(e.Message);
                throw e;
            }

            /*
             * Open a secondary btree database associated with the
             * Inventory database.
             */
            try {
                itemSecbtreeConfig = new SecondaryBTreeDatabaseConfig(
                    ibtreeDB, new SecondaryKeyGenDelegate(
                    CreateSecondaryKey));

                itemSecbtreeConfig.Creation = CreatePolicy.IF_NEEDED;
                itemSecbtreeConfig.Duplicates = DuplicatesPolicy.UNSORTED;
                itemSecbtreeDB = SecondaryBTreeDatabase.Open(
                    itemSDbName, itemSecbtreeConfig);
            } catch (Exception e) {
                Console.WriteLine("Error opening secondary {0}", itemSDbName);
                Console.WriteLine(e.Message);
                throw e;
            }
        }
开发者ID:simonzhangsm,项目名称:h-store,代码行数:65,代码来源:MyDbs.cs

示例13: InitDbs

        /* Initialize environment and database (s) */
        public void InitDbs()
        {
            /* Open transactional environment */
            DatabaseEnvironmentConfig envConfig =
                new DatabaseEnvironmentConfig();
            envConfig.Create = true;
            envConfig.UseMPool = true;
            envConfig.UseLocking = true;
            envConfig.UseLogging = true;
            envConfig.UseTxns = true;
            envConfig.LockSystemCfg = new LockingConfig();
            envConfig.LockSystemCfg.MaxLocks =
                (this.dups == 0) ?
                (uint)this.num :
                (uint)(this.num * this.dups);
            envConfig.LockSystemCfg.MaxObjects =
                envConfig.LockSystemCfg.MaxLocks;
            if (this.cachesize != 0) {
                envConfig.MPoolSystemCfg = new MPoolConfig();
                envConfig.MPoolSystemCfg.CacheSize =
                    new CacheInfo(0, this.cachesize, 1);
            }

            try {
                env = DatabaseEnvironment.Open(home, envConfig);
            } catch (Exception e) {
                Console.WriteLine(e.StackTrace);
                System.Environment.Exit(1);
            }

            Transaction txn = env.BeginTransaction();

            try {
                /* Open primary db in transaction */
                BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
                dbConfig.Env = env;
                dbConfig.Creation = CreatePolicy.IF_NEEDED;
                if (this.pagesize != 0)
                    dbConfig.PageSize = this.pagesize;
                if (this.dups != 0)
                    dbConfig.Duplicates = DuplicatesPolicy.UNSORTED;
                pdb = BTreeDatabase.Open(dbFileName, pDbName, dbConfig, txn);

                /* Open secondary db in transaction */
                if (this.secondary) {
                    SecondaryBTreeDatabaseConfig sdbConfig =
                        new SecondaryBTreeDatabaseConfig(
                        pdb, new SecondaryKeyGenDelegate(SecondaryKeyGen));
                    sdbConfig.Creation = CreatePolicy.IF_NEEDED;
                    if (this.pagesize != 0)
                        sdbConfig.PageSize = this.pagesize;
                    sdbConfig.Duplicates = DuplicatesPolicy.SORTED;
                    sdbConfig.Env = env;
                    sdb = SecondaryBTreeDatabase.Open(
                        dbFileName, sDbName, sdbConfig, txn);
                }

                txn.Commit();
            } catch (DatabaseException e1) {
                txn.Abort();
                throw e1;
            } catch (FileNotFoundException e2) {
                txn.Abort();
                throw e2;
            }
        }
开发者ID:simonzhangsm,项目名称:h-store,代码行数:67,代码来源:excs_bulk.cs

示例14: TestPrefixCompare

        public void TestPrefixCompare()
        {
            testName = "TestPrefixCompare";
            SetUpTest(true);
            string dbFileName = testHome + "/" + testName + ".db";

            // Open a primary btree database.
            BTreeDatabaseConfig btreeDBConfig =
                new BTreeDatabaseConfig();
            btreeDBConfig.Creation = CreatePolicy.ALWAYS;
            BTreeDatabase btreeDB = BTreeDatabase.Open(
                dbFileName, btreeDBConfig);

            // Open a secondary btree database.
            SecondaryBTreeDatabaseConfig secBtreeDBConfig =
                new SecondaryBTreeDatabaseConfig(btreeDB, null);
            secBtreeDBConfig.Primary = btreeDB;
            secBtreeDBConfig.Compare =
                new EntryComparisonDelegate(
                SecondaryEntryComparison);
            secBtreeDBConfig.PrefixCompare =
                new EntryPrefixComparisonDelegate(
                SecondaryPrefixEntryComparison);
            secBtreeDBConfig.KeyGen =
                new SecondaryKeyGenDelegate(
                SecondaryKeyGen);
            SecondaryBTreeDatabase secDB =
                SecondaryBTreeDatabase.Open(
                dbFileName, secBtreeDBConfig);

            /*
             * Get the prefix compare function set in the
             * configuration and run it in a comparison to
             * see if it is alright.
             */
            EntryPrefixComparisonDelegate cmp =
                secDB.PrefixCompare;
            DatabaseEntry dbt1, dbt2;
            dbt1 = new DatabaseEntry(
                BitConverter.GetBytes((Int32)1));
            dbt2 = new DatabaseEntry(
                BitConverter.GetBytes((Int64)4294967297));
            Assert.AreEqual(5, cmp(dbt1, dbt2));

            secDB.Close();
            btreeDB.Close();
        }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:47,代码来源:SecondaryBTreeDatabaseTest.cs

示例15: TestOpen

        public void TestOpen()
        {
            testName = "TestOpen";
            SetUpTest(true);
            string dbFileName = testHome + "/" + testName + ".db";
            string dbSecFileName = testHome + "/" +
                testName + "_sec.db";

            XmlElement xmlElem = Configuration.TestSetUp(
                testFixtureName, testName);

            // Open a primary btree database.
            BTreeDatabaseConfig btreeDBConfig =
                new BTreeDatabaseConfig();
            btreeDBConfig.Creation = CreatePolicy.IF_NEEDED;
            BTreeDatabase btreeDB = BTreeDatabase.Open(
                dbFileName, btreeDBConfig);

            // Open a secondary btree database.
            SecondaryBTreeDatabaseConfig secDBConfig =
                new SecondaryBTreeDatabaseConfig(btreeDB, null);

            SecondaryBTreeDatabaseConfigTest.Config(xmlElem,
                ref secDBConfig, true);
            SecondaryBTreeDatabase secDB =
               SecondaryBTreeDatabase.Open(dbSecFileName,
               secDBConfig);

            // Confirm its flags configured in secDBConfig.
            Confirm(xmlElem, secDB, true);

            secDB.Close();
            btreeDB.Close();
        }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:34,代码来源:SecondaryBTreeDatabaseTest.cs


注:本文中的BerkeleyDB.SecondaryBTreeDatabaseConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。