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

C# BerkeleyDB.BTreeDatabaseConfig类代码示例

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

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



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

示例1: ConfigCase1

 public void ConfigCase1(BTreeDatabaseConfig dbConfig)
 {
     dbConfig.Creation = CreatePolicy.IF_NEEDED;
     dbConfig.Duplicates = DuplicatesPolicy.UNSORTED;
     dbConfig.PageSize = 4096;
     dbConfig.MinKeysPerPage = 10;
 }
开发者ID:remotesyssupport,项目名称:omnibus,代码行数:7,代码来源:BTreeDatabaseTest.cs


示例2: Config

        private void Config(BTreeDatabaseConfig cfg) {
            base.Config(cfg);
            /* 
             * Database.Config calls set_flags, but that does not get the BTree
             * specific flags.  No harm in calling it again.
             */
            db.set_flags(cfg.flags);

            if (cfg.BlobDir != null && cfg.Env == null)
                db.set_blob_dir(cfg.BlobDir);

            if (cfg.blobThresholdIsSet)
                db.set_blob_threshold(cfg.BlobThreshold, 0);

            if (cfg.BTreeCompare != null)
                Compare = cfg.BTreeCompare;

            if (cfg.BTreePrefixCompare != null)
                PrefixCompare = cfg.BTreePrefixCompare;

            // The duplicate comparison function cannot change.
            if (cfg.DuplicateCompare != null)
                DupCompare = cfg.DuplicateCompare;

            if (cfg.minkeysIsSet)
                db.set_bt_minkey(cfg.MinKeysPerPage);
                
            if (cfg.compressionIsSet) {
                Compress = cfg.Compress;
                Decompress = cfg.Decompress;
                if (Compress == null)
                    doCompressRef = null;
                else
                    doCompressRef = new BDB_CompressDelegate(doCompress);
                if (Decompress == null)
                    doDecompressRef = null;
                else
                    doDecompressRef = new BDB_DecompressDelegate(doDecompress);
                db.set_bt_compress(doCompressRef, doDecompressRef);
            }

            if (cfg.partitionIsSet) {
                nparts = cfg.NParts;
                Partition = cfg.Partition;
                if (Partition == null)
                    doPartitionRef = null;
                else
                    doPartitionRef = new BDB_PartitionDelegate(doPartition);
                partitionKeys = cfg.PartitionKeys;
                IntPtr[] ptrs = null;
                if (partitionKeys != null) {
                    int size = (int)nparts - 1;
                    ptrs = new IntPtr[size];
                    for (int i = 0; i < size; i++)
                        ptrs[i] = DBT.getCPtr(
                            DatabaseEntry.getDBT(partitionKeys[i])).Handle;
                }
                db.set_partition(nparts, ptrs, doPartitionRef);
            }
        }
开发者ID:rohitlodha,项目名称:DenverDB,代码行数:60,代码来源:BTreeDatabase.cs


示例3: OpenBase

        private void OpenBase()
        {
            var pathStr = Environment.GetEnvironmentVariable("PATH");

            var pwd = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            pwd = Path.Combine(pwd, IntPtr.Size == 4 ? "x86" : "x64");
            if (pathStr != null && !pathStr.Contains(pwd))
            {
                pwd += ";" + Environment.GetEnvironmentVariable("PATH");
                Environment.SetEnvironmentVariable("PATH", pwd);
            }


            _btreeConfig = new BTreeDatabaseConfig
            {
                Duplicates = DuplicatesPolicy.NONE,
                ErrorPrefix = "QH_" + Path.GetFileName(_dbPAth),
                Creation = CreatePolicy.IF_NEEDED,
                FreeThreaded = true
            };

            if (_env != null)
            {
                _btreeConfig.Env = _env;
            }

            _btreeDb = BTreeDatabase.Open(_dbPAth, _name, _btreeConfig);
        }
开发者ID:SoftFx,项目名称:PerformancePoC,代码行数:28,代码来源:BdbStorage.cs


示例4: Config

        private void Config(BTreeDatabaseConfig cfg) {
            base.Config(cfg);
            /* 
             * Database.Config calls set_flags, but that doesn't get the BTree
             * specific flags.  No harm in calling it again.
             */
            db.set_flags(cfg.flags);
            
            if (cfg.BTreeCompare != null)
                Compare = cfg.BTreeCompare;

            if (cfg.BTreePrefixCompare != null)
                PrefixCompare = cfg.BTreePrefixCompare;

            // The duplicate comparison function cannot change.
            if (cfg.DuplicateCompare != null)
                DupCompare = cfg.DuplicateCompare;

            if (cfg.minkeysIsSet)
                db.set_bt_minkey(cfg.MinKeysPerPage);
                
            if (cfg.compressionIsSet) {
                Compress = cfg.Compress;
                Decompress = cfg.Decompress;
                if (Compress == null)
                    doCompressRef = null;
                else
                    doCompressRef = new BDB_CompressDelegate(doCompress);
                if (Decompress == null)
                    doDecompressRef = null;
                else
                    doDecompressRef = new BDB_DecompressDelegate(doDecompress);
                db.set_bt_compress(doCompressRef, doDecompressRef);
            }
        }
开发者ID:gildafnai82,项目名称:craq,代码行数:35,代码来源:BTreeDatabase.cs


示例5: GetCursorInBtreeDBUsingRecno

        public void GetCursorInBtreeDBUsingRecno(string home,
		    string name, out BTreeDatabase db,
		    out BTreeCursor cursor)
        {
            string dbFileName = home + "/" + name + ".db";
            BTreeDatabaseConfig dbConfig = new BTreeDatabaseConfig();
            dbConfig.UseRecordNumbers = true;
            dbConfig.Creation = CreatePolicy.IF_NEEDED;
            db = BTreeDatabase.Open(dbFileName, dbConfig);
            cursor = db.Cursor();
        }
开发者ID:sukantoguha,项目名称:INET-Vagrant-Demos,代码行数:11,代码来源:BTreeCursorTest.cs


示例6: Init

        public override void Init(int flowCount, long flowRecordCount)
        {
            BTreeDatabaseConfig config = new BTreeDatabaseConfig();

            config.Creation = CreatePolicy.IF_NEEDED;
            config.CacheSize = new CacheInfo(5, 0, 2);
            config.PageSize = 8 * 1024;
            config.BTreeCompare = new EntryComparisonDelegate(CompareFunctionKeyByteArray);
            config.Duplicates = DuplicatesPolicy.NONE;

            string fileName = Path.Combine(DataDirectory, string.Format("{0}.oracle", CollectionName));
            database = BTreeDatabase.Open(fileName, config);
        }
开发者ID:pavel-gridnev,项目名称:DatabaseBenchmark,代码行数:13,代码来源:OracleBerkeleyDBDatabase.cs


示例7: 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


示例8: 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


示例9: OpenBtreeDBInEnv

        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);
        }
开发者ID:jamiekeefer,项目名称:gldcoin,代码行数:18,代码来源:TransactionTest.cs


示例10: Open

        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);
        }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:20,代码来源:TransactionCommitTokenTest.cs


示例11: Confirm

        public static void Confirm(XmlElement
		    xmlElement, BTreeDatabaseConfig btreeDBConfig,
		    bool compulsory)
        {
            DatabaseConfig dbConfig = btreeDBConfig;
            Confirm(xmlElement, dbConfig, compulsory);

            // Confirm Btree database specific configuration
            Configuration.ConfirmDuplicatesPolicy(xmlElement,
                "Duplicates", btreeDBConfig.Duplicates, compulsory);
            Configuration.ConfirmBool(xmlElement,
                "NoReverseSplitting",
                btreeDBConfig.NoReverseSplitting, compulsory);
            Configuration.ConfirmBool(xmlElement,
                "UseRecordNumbers", btreeDBConfig.UseRecordNumbers,
                compulsory);
            Configuration.ConfirmCreatePolicy(xmlElement,
                "Creation", btreeDBConfig.Creation, compulsory);
            Configuration.ConfirmUint(xmlElement, "MinKeysPerPage",
                btreeDBConfig.MinKeysPerPage, compulsory);
        }
开发者ID:simonzhangsm,项目名称:h-store,代码行数:21,代码来源:BTreeDatabaseConfigTest.cs


示例12: TestConfig

        public virtual void TestConfig()
        {
            testName = "TestConfig";
            SetUpTest(true);
            string dbFileName = testHome + "/" + testName;

            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);

            SecondaryDatabaseConfig secDBConfig =
                new SecondaryDatabaseConfig(btreeDB, null);
            Config(xmlElem, ref secDBConfig, true);
            Confirm(xmlElem, secDBConfig, true);
            btreeDB.Close();
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:22,代码来源:SecondaryDatabaseConfigTest.cs


示例13: Config

        public static void Config(XmlElement xmlElement,
		    ref BTreeDatabaseConfig btreeDBConfig, bool compulsory)
        {
            uint minKeysPerPage = new uint();
            DatabaseConfig dbConfig = btreeDBConfig;
            Config(xmlElement, ref dbConfig, compulsory);

            // Configure specific fields/properties of Btree db
            Configuration.ConfigDuplicatesPolicy(xmlElement,
                "Duplicates", ref btreeDBConfig.Duplicates,
                compulsory);
            Configuration.ConfigBool(xmlElement,
                "NoReverseSplitting",
                ref btreeDBConfig.NoReverseSplitting, compulsory);
            Configuration.ConfigBool(xmlElement,
                "UseRecordNumbers",
                ref btreeDBConfig.UseRecordNumbers, compulsory);
            Configuration.ConfigCreatePolicy(xmlElement,
                "Creation", ref btreeDBConfig.Creation, compulsory);
            if (Configuration.ConfigUint(xmlElement,
                "MinKeysPerPage", ref minKeysPerPage, compulsory))
                btreeDBConfig.MinKeysPerPage = minKeysPerPage;
        }
开发者ID:simonzhangsm,项目名称:h-store,代码行数:23,代码来源:BTreeDatabaseConfigTest.cs


示例14: OpenNewSequence

        public void OpenNewSequence(string dbFileName,
		    out BTreeDatabase db, out Sequence seq)
        {
            // Open a database.
            BTreeDatabaseConfig btreeDBConfig =
                new BTreeDatabaseConfig();
            btreeDBConfig.Creation = CreatePolicy.IF_NEEDED;
            db = BTreeDatabase.Open(dbFileName, btreeDBConfig);

            // Configure and initialize sequence.
            SequenceConfig seqConfig = new SequenceConfig();
            seqConfig.BackingDatabase = db;
            seqConfig.CacheSize = 1000;
            seqConfig.Creation = CreatePolicy.ALWAYS;
            seqConfig.Decrement = false;
            seqConfig.FreeThreaded = true;
            seqConfig.Increment = true;
            seqConfig.InitialValue = 100;
            seqConfig.key = new DatabaseEntry(
                ASCIIEncoding.ASCII.GetBytes("key"));
            seqConfig.SetRange(Int64.MinValue, Int64.MaxValue);
            seqConfig.Wrap = true;
            seq = new Sequence(seqConfig);
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:24,代码来源:SequenceTest.cs


示例15: OpenNewSequenceInEnv

        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();
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:36,代码来源:SequenceTest.cs


示例16: 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;
            String keyStr = "key";
            key = new DatabaseEntry();
            Configuration.dbtFromString(key, keyStr);

            data = new DatabaseEntry();
            String[] dataStrs = { "abc", "def", "ghi", "jkl" };
            String dataStr = String.Join(",", dataStrs);
            Configuration.dbtFromString(data, dataStr);
            btreeDB.Put(key, data);

            foreach (String skeyStr in dataStrs) {
                DatabaseEntry skey = new DatabaseEntry();
                Configuration.dbtFromString(skey, skeyStr);
                Assert.IsTrue(secDB.Exists(skey));
            }

            /*
             * Check that a single secondary key, returned in a
             * MultipleDatabaseEntry works.
             */
            keyStr = "key2";
            key = new DatabaseEntry();
            Configuration.dbtFromString(key, keyStr);

            data = new DatabaseEntry();
            dataStrs = new string[1]{ "abcdefghijkl" };
            dataStr = String.Join(",", dataStrs);
            Configuration.dbtFromString(data, dataStr);
            btreeDB.Put(key, data);

            // Check that secondary keys work
            foreach (String skeyStr in dataStrs) {
                DatabaseEntry skey = new DatabaseEntry();
                Configuration.dbtFromString(skey, skeyStr);
                Assert.IsTrue(secDB.Exists(skey));
            }
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:63,代码来源:SecondaryDatabaseTest.cs


示例17: TestKeyGen

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

            // Open primary database.
            BTreeDatabaseConfig primaryDBConfig =
                new BTreeDatabaseConfig();
            primaryDBConfig.Creation = CreatePolicy.IF_NEEDED;
            BTreeDatabase primaryDB =
                BTreeDatabase.Open(dbFileName, primaryDBConfig);

            // Open secondary database.
            SecondaryBTreeDatabaseConfig secDBConfig =
                new SecondaryBTreeDatabaseConfig(primaryDB,
                new SecondaryKeyGenDelegate(SecondaryKeyGen));
            SecondaryBTreeDatabase secDB =
                SecondaryBTreeDatabase.Open(dbFileName,
                secDBConfig);

            primaryDB.Put(new DatabaseEntry(
                BitConverter.GetBytes((int)1)),
                new DatabaseEntry(BitConverter.GetBytes((int)11)));

            KeyValuePair<DatabaseEntry, DatabaseEntry> pair;
            pair = secDB.Get(new DatabaseEntry(
                BitConverter.GetBytes((int)11)));
            Assert.IsNotNull(pair.Value);

            // Close secondary database.
            secDB.Close();

            // Close primary database.
            primaryDB.Close();
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:36,代码来源:SecondaryDatabaseTest.cs


示例18: 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


示例19: TestBadSecondaryException

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

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

            // Open secondary database.
            SecondaryBTreeDatabaseConfig secBtDbConfig =
                new SecondaryBTreeDatabaseConfig(btreeDB,
                new SecondaryKeyGenDelegate(SecondaryKeyGen));
            secBtDbConfig.Creation = CreatePolicy.IF_NEEDED;
            SecondaryBTreeDatabase secBtDb =
                SecondaryBTreeDatabase.Open(secDBFileName,
                secBtDbConfig);

            // Put some data into primary database.
            for (int i = 0; i < 10; i++)
                btreeDB.Put(new DatabaseEntry(
                    BitConverter.GetBytes(i)),
                    new DatabaseEntry(BitConverter.GetBytes(i)));

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

            // Delete record(5, 5) in primary database.
            btreeDB.Delete(new DatabaseEntry(
                BitConverter.GetBytes((int)5)));

            // Reopen the secondary database.
            SecondaryDatabase secDB = SecondaryDatabase.Open(
                secDBFileName,
                new SecondaryDatabaseConfig(btreeDB,
                new SecondaryKeyGenDelegate(SecondaryKeyGen)));

            /*
             * Getting record(5, 5) by secondary database should
             * throw BadSecondaryException since it has been
             * deleted in the primary database.
             */
            try
            {
                secDB.Exists(new DatabaseEntry(
                    BitConverter.GetBytes((int)5)));
            }
            catch (BadSecondaryException)
            {
                throw new ExpectedTestException();
            }
            finally
            {
                secDB.Close();
                btreeDB.Close();
            }
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:63,代码来源:SecondaryDatabaseTest.cs


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# BerkeleyDB.CursorConfig类代码示例发布时间:2022-05-24
下一篇:
C# BerkeleyDB.BTreeDatabase类代码示例发布时间: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