• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# BerkeleyDB.SecondaryBTreeDatabaseConfig类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: TestDuplicates

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

            // 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 secBtreeDBConfig =
                new SecondaryBTreeDatabaseConfig(btreeDB, null);
            secBtreeDBConfig.Creation = CreatePolicy.IF_NEEDED;
            secBtreeDBConfig.Duplicates = DuplicatesPolicy.SORTED;
            SecondaryBTreeDatabase secDB =
                SecondaryBTreeDatabase.Open(dbSecFileName,
                secBtreeDBConfig);
            Assert.AreEqual(DuplicatesPolicy.SORTED, secDB.Duplicates);

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


示例17: TestDupCompare

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

            BTreeDatabaseConfig cfg =
                new BTreeDatabaseConfig();
            cfg.Creation = CreatePolicy.ALWAYS;
            BTreeDatabase pDb = BTreeDatabase.Open(
                dbFileName, "p", cfg);

            SecondaryBTreeDatabaseConfig sCfg =
                new SecondaryBTreeDatabaseConfig(pDb,
                new SecondaryKeyGenDelegate(SecondaryKeyGen));
            sCfg.Creation = CreatePolicy.IF_NEEDED;

            DatabaseEntry dbt1, dbt2;
            dbt1 = new DatabaseEntry(
                BitConverter.GetBytes((Int32)1));
            dbt2 = new DatabaseEntry(
                BitConverter.GetBytes((Int64)4294967297));

            // Do not set the duplicate comparison delegate.
            using (SecondaryBTreeDatabase sDb =
                SecondaryBTreeDatabase.Open(dbFileName, "s1", sCfg)) {
                try {
                    int ret = sDb.DupCompare(dbt1, dbt2);
                    throw new TestException();
                } catch (NullReferenceException) {
                }
            }

            sCfg.DuplicateCompare = new EntryComparisonDelegate(
                SecondaryEntryComparison);
            using (SecondaryBTreeDatabase sDb =
                SecondaryBTreeDatabase.Open(dbFileName, "s2", sCfg)) {
                /*
                 * Get the dup compare function set in the
                 * configuration and run it in a comparison to
                 * see if it is alright.
                 */
                int ret = 1 - BitConverter.ToInt32(
                    BitConverter.GetBytes((Int64)4294967297), 0);

                Assert.AreEqual(ret, sDb.DupCompare(dbt1, dbt2));
            }
            pDb.Close();
        }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:49,代码来源:SecondaryBTreeDatabaseTest.cs


示例18: TestDuplicate

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

            // Open a primary database.
            BTreeDatabaseConfig dbConfig =
                new BTreeDatabaseConfig();
            dbConfig.Creation = CreatePolicy.IF_NEEDED;
            BTreeDatabase 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.UNSORTED;
            SecondaryBTreeDatabase secDB =
                SecondaryBTreeDatabase.Open(dbSecFileName,
                secConfig);

            // Put a pair of key and data into the database.
            DatabaseEntry key, data;
            key = new DatabaseEntry(
                ASCIIEncoding.ASCII.GetBytes("key"));
            data = new DatabaseEntry(
                ASCIIEncoding.ASCII.GetBytes("data"));
            db.Put(key, data);

            // Create a cursor.
            SecondaryCursor cursor = secDB.SecondaryCursor();
            cursor.Move(key, true);

            // Duplicate the cursor.
            SecondaryCursor dupCursor;
            dupCursor = cursor.Duplicate(true);

            /*
             * Confirm that the duplicate cursor has the same
             * position as the original one.
             */
            Assert.AreEqual(cursor.Current.Key,
                dupCursor.Current.Key);
            Assert.AreEqual(cursor.Current.Value,
                dupCursor.Current.Value);

            // Close the cursor and the duplicate cursor.
            dupCursor.Close();
            cursor.Close();

            // Close secondary and primary database.
            secDB.Close();
            db.Close();
        }
开发者ID:mcandre,项目名称:db,代码行数:58,代码来源:SecondaryCursorTest.cs


示例19: TestMultiKeyGen

        public void TestMultiKeyGen()
        {
            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.KeyGen =
                new SecondaryKeyGenDelegate(
                MultipleKeyGen);
            SecondaryBTreeDatabase secDB =
                SecondaryBTreeDatabase.Open(
                dbFileName, secBtreeDBConfig);

            /* Check that multiple secondary keys work */
            DatabaseEntry key, data; 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BerkeleyDB.Transaction类代码示例发布时间:2022-05-24
下一篇:
C# BerkeleyDB.RecnoDatabaseConfig类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap