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

C# BerkeleyDB.LockingInfo类代码示例

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

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



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

示例1: Move

        /// <summary>
        /// Position the cursor at a specific key/data pair in the database, and
        /// store the key/data pair in <see cref="Cursor.Current"/>.
        /// </summary>
        /// <param name="recno">
        /// The specific numbered record of the database at which to position
        /// the cursor.
        /// </param>
        /// <param name="info">The locking behavior to use</param>
        /// <returns>
        /// True if the cursor was positioned successfully, false otherwise.
        /// </returns>
        public bool Move(uint recno, LockingInfo info) {
            DatabaseEntry key = new DatabaseEntry();
            key.Data = BitConverter.GetBytes(recno);
            DatabaseEntry data = new DatabaseEntry();

            return base.Get(key, data, DbConstants.DB_SET_RECNO, info);
        }
开发者ID:rohitlodha,项目名称:DenverDB,代码行数:19,代码来源:BTreeCursor.cs


示例2: MoveCursorToRecno

        /*
         * Move the cursor according to recno. The recno
         * starts from 1 and is increased by 1.
         */
        public void MoveCursorToRecno(BTreeCursor cursor,
		    LockingInfo lck)
        {
            for (uint i = 1; i <= 5; i++)
                if (lck == null)
                    Assert.IsTrue(cursor.Move(i));
                else
                    Assert.IsTrue(cursor.Move(i, lck));
        }
开发者ID:sukantoguha,项目名称:INET-Vagrant-Demos,代码行数:13,代码来源:BTreeCursorTest.cs


示例3: GetBothMultiple

        /// <summary>
        /// If a key/data pair in the database matches <paramref name="key"/>
        /// and <paramref name="data"/>, return the key and all duplicate data
        /// items.
        /// </summary>
        /// <param name="key">The key to search for</param>
        /// <param name="data">The data to search for</param>
        /// <param name="BufferSize">
        /// The initial size of the buffer to fill with duplicate data items. If
        /// the buffer is not large enough, it is automatically resized.
        /// </param>
        /// <param name="txn">
        /// <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>
        /// <param name="info">The locking behavior to use.</param>
        /// <exception cref="NotFoundException">
        /// A NotFoundException is thrown if <paramref name="key"/> and
        /// <paramref name="data"/> are not in the database. 
        /// </exception>
        /// <exception cref="KeyEmptyException">
        /// A KeyEmptyException is thrown if the database is a
        /// <see cref="QueueDatabase"/> or <see cref="RecnoDatabase"/> 
        /// database and <paramref name="key"/> exists, but was never explicitly
        /// created by the application or was later deleted.
        /// </exception>
        /// <returns>
        /// A <see cref="KeyValuePair{T,T}"/>
        /// whose Key parameter is <paramref name="key"/> and whose Value
        /// parameter is the retrieved data items.
        /// </returns>
        public KeyValuePair<DatabaseEntry, MultipleDatabaseEntry> GetBothMultiple(
            DatabaseEntry key, DatabaseEntry data,
            int BufferSize, Transaction txn, LockingInfo info)
        {
            KeyValuePair<DatabaseEntry, DatabaseEntry> kvp;
            int datasz = (int)data.Data.Length;

            for (; ; ) {
                byte[] udata = new byte[BufferSize];
                Array.Copy(data.Data, udata, datasz);
                data.UserData = udata;
                data.size = (uint)datasz;
                try {
                    kvp = Get(key, data, txn, info,
                        DbConstants.DB_MULTIPLE | DbConstants.DB_GET_BOTH);
                    break;
                } catch (MemoryException) {
                    int sz = (int)data.size;
                    if (sz > BufferSize)
                        BufferSize = sz;
                    else
                        BufferSize *= 2;
                }
            }
            MultipleDatabaseEntry dbe = new MultipleDatabaseEntry(kvp.Value);
            return new KeyValuePair<DatabaseEntry, MultipleDatabaseEntry>(
                kvp.Key, dbe);
        }
开发者ID:simonzhangsm,项目名称:h-store,代码行数:62,代码来源:Database.cs


示例4: MoveMultipleKey

        /// <summary>
        /// Position the cursor at a specific key/data pair in the database, and
        /// store the key/data pair and as many ensuing key/data pairs that can
        /// fit in a buffer the size of one database page in
        /// <see cref="Cursor.CurrentMultipleKey"/>.
        /// </summary>
        /// <param name="recno">
        /// The specific numbered record of the database at which to position
        /// the cursor.
        /// </param>
        /// <param name="BufferSize">
        /// The size of a buffer to fill with key/data pairs.  Must be at least
        /// the page size of the underlying database and be a multiple of 1024.
        /// </param>
        /// <param name="info">The locking behavior to use</param>
        /// <returns>
        /// True if the cursor was positioned successfully, false otherwise.
        /// </returns>
        public bool MoveMultipleKey(
            uint recno, int BufferSize, LockingInfo info)
        {
            DatabaseEntry key = new DatabaseEntry();
            key.Data = BitConverter.GetBytes(recno);
            DatabaseEntry data = new DatabaseEntry();

            return base.GetMultiple(
                key, data, BufferSize, DbConstants.DB_SET_RECNO, info, true);
        }
开发者ID:hyc,项目名称:BerkeleyDB,代码行数:28,代码来源:BTreeCursor.cs


示例5: TestMoveNextWithLockingInfo

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

            /*
             * Open environment, primary database and
             * secondary database.
             */
            BTreeDatabase db;
            DatabaseEnvironment env;
            SecondaryBTreeDatabase secDB;
            OpenSecDBInTxn(testHome, dbFileName, dbSecFileName,
                out env, out db, out secDB);

            // Write ten records into the database.
            WriteRecordsInTxn(db, env);

            /*
             * Move cursor to the first record and move to next
             * record for five times.
             */
            Transaction cursorTxn = env.BeginTransaction();
            SecondaryCursor cursor =
                secDB.SecondaryCursor(cursorTxn);
            LockingInfo lockingInfo = new LockingInfo();
            lockingInfo.IsolationDegree = Isolation.DEGREE_THREE;
            lockingInfo.ReadModifyWrite = true;
            cursor.MoveFirst(lockingInfo);
            for (int i = 0; i < 5; i++) {
                Assert.IsTrue(cursor.MoveNext(lockingInfo));

                cursor.MovePrev(lockingInfo);

                Assert.IsTrue(cursor.MoveNext(
                    new DatabaseEntry(0, 1),
                    new DatabaseEntry(),
                    new DatabaseEntry(2, 2), lockingInfo));
                CheckPartial(cursor.Current.Key, 0, 1, null, 0,
                    0, cursor.Current.Value.Value, 2, 2);

                /* Disable the test.
                Assert.IsTrue(cursor.MoveNext(
                    new DatabaseEntry(0, 1),
                    new DatabaseEntry(1, 1),
                    new DatabaseEntry(2, 2), lockingInfo));
                CheckPartial(cursor.Current.Key, 0, 1,
                    cursor.Current.Value.Key, 1, 1,
                    cursor.Current.Value.Value, 2, 2);*/
            }

            cursor.Close();
            cursorTxn.Commit();

            // Close all.
            secDB.Close();
            db.Close();
            env.Close();
        }
开发者ID:mcandre,项目名称:db,代码行数:61,代码来源:SecondaryCursorTest.cs


示例6: TestMoveLastWithLockingInfo

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

            /*
             * Open environment, primary database and
             * secondary database.
             */
            BTreeDatabase db;
            DatabaseEnvironment env;
            SecondaryBTreeDatabase secDB;
            OpenSecDBInTxn(testHome, dbFileName, dbSecFileName,
                out env, out db, out secDB);

            // Write ten records into the database.
            WriteRecordsInTxn(db, env);

            /*
             * Move the cursor to the last record(10, 6), that is
             * record(6, 10) in primary database.
             */
            Transaction cursorTxn = env.BeginTransaction();
            SecondaryCursor cursor =
                secDB.SecondaryCursor(cursorTxn);
            LockingInfo lockingInfo = new LockingInfo();
            lockingInfo.IsolationDegree = Isolation.DEGREE_THREE;
            lockingInfo.ReadModifyWrite = true;
            Assert.IsTrue(cursor.MoveLast(lockingInfo));
            Assert.AreEqual(BitConverter.GetBytes((int)10),
                cursor.Current.Key.Data);

            Assert.IsTrue(cursor.MoveLast(
                new DatabaseEntry(0, 1),
                new DatabaseEntry(),
                new DatabaseEntry(2, 2), lockingInfo));
            CheckPartial(cursor.Current.Key, 0, 1, null, 0, 0,
                cursor.Current.Value.Value, 2, 2);

            /* Disable the test.
            Assert.IsTrue(cursor.MoveLast(
                new DatabaseEntry(0, 1),
                new DatabaseEntry(1, 1),
                new DatabaseEntry(2, 2), lockingInfo));
            CheckPartial(cursor.Current.Key, 0, 1,
                cursor.Current.Value.Key, 1, 1,
                cursor.Current.Value.Value, 2, 2);*/

            cursor.Close();
            cursorTxn.Commit();

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


示例7: MoveToPosWithLockingInfo

        public void MoveToPosWithLockingInfo(string home, 
		    string dbFileName, string dbSecFileName, bool ifPair)
        {
            // Open a primary database and its secondary database.
            BTreeDatabase db;
            DatabaseEnvironment env;
            SecondaryBTreeDatabase secDB;
            OpenSecDBInTxn(home, dbFileName, dbSecFileName,
                out env, out db, out secDB);

            // Write ten records into the database.
            WriteRecordsInTxn(db, env);

            // Create an secondary cursor.
            Transaction cursorTxn = env.BeginTransaction();
            SecondaryCursor secCursor = secDB.SecondaryCursor(
                cursorTxn);
            DatabaseEntry key = new DatabaseEntry(
                BitConverter.GetBytes((int)0));
            LockingInfo lockingInfo = new LockingInfo();
            lockingInfo.IsolationDegree = Isolation.DEGREE_THREE;
            lockingInfo.ReadModifyWrite = true;
            if (ifPair == false) {
                Assert.IsTrue(secCursor.Move(
                    key, true, lockingInfo));

                Assert.IsTrue(secCursor.Move(key,
                    new DatabaseEntry(),
                    new DatabaseEntry(2, 2), true));
                CheckPartial(null, 0, 0, null, 0, 0,
                    secCursor.Current.Value.Value, 2, 2);

                /* Disable the test.
                Assert.IsTrue(secCursor.Move(key,
                    new DatabaseEntry(1, 1),
                    new DatabaseEntry(2, 2), true));
                CheckPartial(null, 0, 0,
                    secCursor.Current.Value.Key, 1, 1,
                    secCursor.Current.Value.Value, 2, 2);*/

                byte[] partByte = new byte[] {key.Data[2]};
                key = new DatabaseEntry(partByte, 2, 1);
                Assert.IsTrue(secCursor.Move(key, false));
                CheckPartial(secCursor.Current.Key, 2, 1,
                    null, 0, 0, null, 0, 0);
            } else {
                KeyValuePair<DatabaseEntry, KeyValuePair<
                    DatabaseEntry, DatabaseEntry>> pair;

                pair = new KeyValuePair<DatabaseEntry,
             		KeyValuePair<DatabaseEntry, DatabaseEntry>>(key,
                    new KeyValuePair<DatabaseEntry, DatabaseEntry>(
                    key, key));
                Assert.IsTrue(secCursor.Move(pair, true, lockingInfo));
            }
            secCursor.Close();
            cursorTxn.Commit();

            secDB.Close();
            db.Close();
            env.Close();
        }
开发者ID:mcandre,项目名称:db,代码行数:62,代码来源:SecondaryCursorTest.cs


示例8: MoveCursorToPrevUnique

        /*
         * Move the cursor to previous unique record in a
         * database with more than 2 records. The returning
         * value should be true.
         */
        public void MoveCursorToPrevUnique(Cursor dbc, 
		    LockingInfo lck)
        {
            for (int i = 0; i < 5; i++)
                if (lck == null)
                    dbc.MovePrevUnique();
                else
                    dbc.MovePrevUnique(lck);
        }
开发者ID:gildafnai82,项目名称:craq,代码行数:14,代码来源:CursorTest.cs


示例9: MoveCursorToPrevDuplicate

        /*
         * Move the cursor to a duplicate record and then to
         * another duplicate one. And finally move to it previous
         * one. Since the previous duplicate one exist, the return
         * value of move previous duplicate record should be
         * true;
         */
        public void MoveCursorToPrevDuplicate(Cursor dbc,
		uint kOffset, uint kLen,
		uint dOffset, uint dLen, LockingInfo lck)
        {
            if (lck == null) {
                dbc.Move(new DatabaseEntry(
                    ASCIIEncoding.ASCII.GetBytes("key")), true);
                dbc.MoveNextDuplicate();
                Assert.IsTrue(dbc.MovePrevDuplicate());

                dbc.Move(new DatabaseEntry(
                    ASCIIEncoding.ASCII.GetBytes("key")), true);
                dbc.MoveNextDuplicate();
                Assert.IsTrue(dbc.MovePrevDuplicate(
                    new DatabaseEntry(kOffset, kLen),
                    new DatabaseEntry(dOffset, dLen)));
            } else {
                dbc.Move(new DatabaseEntry(
                    ASCIIEncoding.ASCII.GetBytes("key")),
                    true, lck);
                dbc.MoveNextDuplicate(lck);
                Assert.IsTrue(dbc.MovePrevDuplicate(lck));

                dbc.Move(new DatabaseEntry(
                    ASCIIEncoding.ASCII.GetBytes("key")),
                    true, lck);
                dbc.MoveNextDuplicate(lck);
                Assert.IsTrue(dbc.MovePrevDuplicate(
                    new DatabaseEntry(kOffset, kLen),
                    new DatabaseEntry(dOffset, dLen), lck));
            }

            CheckPartial(dbc.Current.Key, kOffset, kLen,
            dbc.Current.Value, dOffset, dLen);
        }
开发者ID:mcandre,项目名称:db,代码行数:42,代码来源:CursorTest.cs


示例10: MoveCursorToPrev

        /*
         * Move the cursor to previous record in the database.
         * The returning value should be true;
         */
        public void MoveCursorToPrev(Cursor dbc,
		uint kOffset, uint kLen,
		uint dOffset, uint dLen, LockingInfo lck)
        {
            if (lck == null) {
                dbc.MoveLast();
                for (int i = 0; i < 5; i++) {
                    Assert.IsTrue(dbc.MovePrev());
                    dbc.MoveNext();
                    Assert.IsTrue(dbc.MovePrev(
                        new DatabaseEntry(kOffset, kLen),
                        new DatabaseEntry(dOffset, dLen)));
                    CheckPartial(
                        dbc.Current.Key, kOffset, kLen,
                        dbc.Current.Value, dOffset, dLen);
                }
            } else {
                dbc.MoveLast(lck);
                for (int i = 0; i < 5; i++) {
                    Assert.IsTrue(dbc.MovePrev(lck));
                    dbc.MoveNext();
                    Assert.IsTrue(dbc.MovePrev(
                        new DatabaseEntry(kOffset, kLen),
                        new DatabaseEntry(dOffset, dLen),
                        lck));
                    CheckPartial(
                        dbc.Current.Key, kOffset, kLen,
                        dbc.Current.Value, dOffset, dLen);
                }
            }
        }
开发者ID:mcandre,项目名称:db,代码行数:35,代码来源:CursorTest.cs


示例11: MoveCursorToNextUnique

        /*
         * Move the cursor to next unique record in the database.
         * The returning value should be true.
         */
        public void MoveCursorToNextUnique(Cursor dbc,
		uint kOffset, uint kLen,
		uint dOffset, uint dLen, LockingInfo lck)
        {
            for (int i = 0; i < 5; i++) {
                if (lck == null) {
                    Assert.IsTrue(dbc.MoveNextUnique());
                    Assert.IsTrue(dbc.MoveNextUnique(
                        new DatabaseEntry(kOffset, kLen),
                        new DatabaseEntry(dOffset, dLen)));
                } else {
                    Assert.IsTrue(dbc.MoveNextUnique(lck));
                    Assert.IsTrue(dbc.MoveNextUnique(
                        new DatabaseEntry(kOffset, kLen),
                        new DatabaseEntry(dOffset, dLen),
                        lck));
                }
                CheckPartial(dbc.Current.Key, kOffset, kLen,
                    dbc.Current.Value, dOffset, dLen);
            }
        }
开发者ID:mcandre,项目名称:db,代码行数:25,代码来源:CursorTest.cs


示例12: MoveCursorToLast

        /*
         * Move the cursor to last record in a nonempty
         * database. The returning value should be true.
         */
        public void MoveCursorToLast(Cursor dbc,
		    uint kOffset, uint kLen,
		    uint dOffset, uint dLen, LockingInfo lck)
        {
            DatabaseEntry key = new DatabaseEntry(kOffset, kLen);
            DatabaseEntry data = new DatabaseEntry(dOffset, dLen);
            if (lck == null) {
                Assert.IsTrue(dbc.MoveLast());
                Assert.IsTrue(dbc.MoveLast(key, data));
            } else {
                Assert.IsTrue(dbc.MoveLast(lck));
                Assert.IsTrue(dbc.MoveLast(key, data, lck));
            }
            CheckPartial(dbc.Current.Key, kOffset, kLen,
                dbc.Current.Value, dOffset, dLen);
        }
开发者ID:mcandre,项目名称:db,代码行数:20,代码来源:CursorTest.cs


示例13: MoveCursorToCurrentRec

        /*
         * Move the cursor to current existing record. The returning
         * value should be true.
         */
        public void MoveCursorToCurrentRec(Cursor dbc,
		    uint kOffset, uint kLen,
		    uint dOffset, uint dLen, LockingInfo lck)
        {
            DatabaseEntry key, data;

            // Add a record to the database.
            KeyValuePair<DatabaseEntry, DatabaseEntry> pair;
            key = new DatabaseEntry(
                ASCIIEncoding.ASCII.GetBytes("key"));
            data = new DatabaseEntry(
                ASCIIEncoding.ASCII.GetBytes("data"));
            pair = new KeyValuePair<DatabaseEntry,
                DatabaseEntry>(key, data);
            dbc.Add(pair);

            if (lck == null)
                Assert.IsTrue(dbc.Refresh());
            else
            Assert.IsTrue(dbc.Refresh(lck));
            Assert.AreEqual(key.Data, dbc.Current.Key.Data);
            Assert.AreEqual(data.Data, dbc.Current.Value.Data);

            key = new DatabaseEntry(kOffset, kLen);
            data = new DatabaseEntry(dOffset, dLen);
            if (lck == null)
                Assert.IsTrue(dbc.Refresh(key, data));
            else
                Assert.IsTrue(dbc.Refresh(key, data, lck));
            CheckPartial(dbc.Current.Key, kOffset, kLen,
                dbc.Current.Value, dOffset, dLen);
        }
开发者ID:mcandre,项目名称:db,代码行数:36,代码来源:CursorTest.cs


示例14: MoveCursor

        /*
         * Move the cursor to an exisiting key and key/data
         * pair with LockingInfo.
         */
        public void MoveCursor(Cursor dbc,
		    uint kOffset, uint kLen,
		    uint dOffset, uint dLen,
		    LockingInfo lck)
        {
            DatabaseEntry key, data;
            KeyValuePair<DatabaseEntry, DatabaseEntry> pair;

            key = new DatabaseEntry(
                BitConverter.GetBytes((int)0));
            data = new DatabaseEntry(
                BitConverter.GetBytes((int)0));
            pair = new KeyValuePair<DatabaseEntry,
                DatabaseEntry>(key, data);

            if (lck == null) {
                // Move to an existing key.
                Assert.IsTrue(dbc.Move(key, true));

                // Move to an existing key/data pair.
                Assert.IsTrue(dbc.Move(pair, true));

                /* Move to an existing key, and return
                 * partial data.
                 */
                data = new DatabaseEntry(dOffset, dLen);
                Assert.IsTrue(dbc.Move(key, data, true));
                CheckPartial(null, 0, 0,
                    dbc.Current.Value, dOffset, dLen);

                // Partially key match.
                byte[] partbytes = new byte[kLen];
                for (int i = 0; i < kLen; i++)
                partbytes[i] = BitConverter.GetBytes(
                    (int)1)[kOffset + i];
                key = new DatabaseEntry(partbytes, kOffset, kLen);
                Assert.IsTrue(dbc.Move(key, false));
                Assert.AreEqual(kLen, dbc.Current.Key.Data.Length);
                CheckPartial(dbc.Current.Key, kOffset, kLen,
                    null, 0, 0);
            } else {
                // Move to an existing key.
                Assert.IsTrue(dbc.Move(key, true, lck));

                // Move to an existing key/data pair.
                Assert.IsTrue(dbc.Move(pair, true, lck));

                /*
                 * Move to an existing key, and return
                 * partial data.
                 */
                data = new DatabaseEntry(dOffset, dLen);
                Assert.IsTrue(dbc.Move(key, data, true, lck));
                CheckPartial(null, 0, 0,
                    dbc.Current.Value, dOffset, dLen);

                // Partially key match.
                byte[] partbytes = new byte[kLen];
                for (int i = 0; i < kLen; i++)
                    partbytes[i] = BitConverter.GetBytes(
                        (int)1)[kOffset + i];
                key = new DatabaseEntry(partbytes, kOffset, kLen);
                Assert.IsTrue(dbc.Move(key, false, lck));
                Assert.AreEqual(kLen, dbc.Current.Key.Data.Length);
                CheckPartial(dbc.Current.Key, kOffset, kLen,
                    null, 0, 0);
            }
        }
开发者ID:mcandre,项目名称:db,代码行数:72,代码来源:CursorTest.cs


示例15: TestRefresh

        public void TestRefresh()
        {
            BTreeDatabase db;
            BTreeCursor cursor;
            DatabaseEnvironment env;
            Transaction txn;

            testName = "TestRefresh";
            SetUpTest(true);

            GetCursorInBtreeDBWithoutEnv(testHome, testName,
                out db, out cursor);
            // Write a record with cursor and Refresh the cursor.
            MoveCursorToCurrentRec(cursor, 1, 1, 2, 2, null);
            cursor.Dispose();
            db.Dispose();

            Configuration.ClearDir(testHome);
            GetCursorInBtreeDBInTDS(testHome, testName, null, out env,
                out db, out cursor, out txn);
            LockingInfo lockingInfo = new LockingInfo();
            lockingInfo.IsolationDegree = Isolation.DEGREE_ONE;
            MoveCursorToCurrentRec(cursor, 1, 1, 2, 2, lockingInfo);
            cursor.Close();
            txn.Commit();
            db.Close();
            env.Close();
        }
开发者ID:mcandre,项目名称:db,代码行数:28,代码来源:CursorTest.cs


示例16: MoveCursorToPrev

        /*
         * Move the cursor to previous record in the database.
         * The returning value should be true;
         */
        public void MoveCursorToPrev(Cursor dbc, 
		    LockingInfo lck)
        {
            if (lck == null)
            {
                dbc.MoveLast();
                for (int i = 0; i < 5; i++)
                    Assert.IsTrue(dbc.MovePrev());
            }
            else
            {
                dbc.MoveLast(lck);
                for (int i = 0; i < 5; i++)
                    Assert.IsTrue(dbc.MovePrev(lck));
            }
        }
开发者ID:gildafnai82,项目名称:craq,代码行数:20,代码来源:CursorTest.cs


示例17: MoveCursorToPrevDuplicate

        /*
         * Move the cursor to a duplicate record and then to
         * another duplicate one. And finally move to it previous
         * one. Since the previous duplicate one exist, the return
         * value of move previous duplicate record should be
         * true;
         */
        public void MoveCursorToPrevDuplicate(Cursor dbc, 
		    LockingInfo lck)
        {
            if (lck == null)
            {
                dbc.Move(new DatabaseEntry(
                    ASCIIEncoding.ASCII.GetBytes("key")), true);
                dbc.MoveNextDuplicate();
                Assert.IsTrue(dbc.MovePrevDuplicate());
            }
            else
            {
                dbc.Move(new DatabaseEntry(
                    ASCIIEncoding.ASCII.GetBytes("key")),true, lck);
                dbc.MoveNextDuplicate(lck);
                Assert.IsTrue(dbc.MovePrevDuplicate(lck));
            }
        }
开发者ID:gildafnai82,项目名称:craq,代码行数:25,代码来源:CursorTest.cs


示例18: MoveCursorToPrevUnique

        /*
         * Move the cursor to previous unique record in a
         * database with more than 2 records. The returning
         * value should be true.
         */
        public void MoveCursorToPrevUnique(Cursor dbc,
		uint kOffset, uint kLen,
		uint dOffset, uint dLen, LockingInfo lck)
        {
            DatabaseEntry key = new DatabaseEntry(kOffset, kLen);
            DatabaseEntry data = new DatabaseEntry(dOffset, dLen);
            for (int i = 0; i < 5; i++) {
                if (lck == null) {
                    Assert.IsTrue(dbc.MovePrevUnique());
                    Assert.IsTrue(
                        dbc.MovePrevUnique(key, data));
                } else {
                    Assert.IsTrue(dbc.MovePrevUnique(lck));
                    Assert.IsTrue(
                        dbc.MovePrevUnique(key, data, lck));
                }
                CheckPartial(dbc.Current.Key, kOffset, kLen,
                    dbc.Current.Value, dOffset, dLen);
            }
        }
开发者ID:mcandre,项目名称:db,代码行数:25,代码来源:CursorTest.cs


示例19: RdMfWt

        public void RdMfWt()
        {
            Transaction txn = paramEnv.BeginTransaction();
            Cursor dbc = paramDB.Cursor(txn);

            try
            {
                LockingInfo lck = new LockingInfo();
                lck.ReadModifyWrite = true;

                // Read record.
                cursorFunc(dbc, lck);

                // Block the current thread until event is set.
                signal.WaitOne();

                // Write new records into database.
                DatabaseEntry key = new DatabaseEntry(
                    BitConverter.GetBytes(55));
                DatabaseEntry data = new DatabaseEntry(
                     BitConverter.GetBytes(55));
                dbc.Add(new KeyValuePair<DatabaseEntry,
                     DatabaseEntry>(key, data));

                dbc.Close();
                txn.Commit();
            }
            catch (DeadlockException)
            {
                dbc.Close();
                txn.Abort();
            }
        }
开发者ID:gildafnai82,项目名称:craq,代码行数:33,代码来源:CursorTest.cs


示例20: Get

        /// <summary>
        /// Retrieve a specific numbered key/data pair from the database.
        /// </summary>
        /// <param name="recno">
        /// The record number of the record to be retrieved.
        /// </param>
        /// <param name="txn">
        /// <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>
        /// <param name="info">The locking behavior to use.</param>
        /// <returns>
        /// A <see cref="KeyValuePair{T,T}"/> whose Key
        /// parameter is <paramref name="recno"/> and whose Value parameter is
        /// the retrieved data.
        /// </returns>
        public KeyValuePair<DatabaseEntry, DatabaseEntry> Get(
            uint recno, Transaction txn, LockingInfo info)
        {
            DatabaseEntry key = new DatabaseEntry();
            key.Data = BitConverter.GetBytes(recno);

            return Get(key, null, txn, info, DbConstants.DB_SET_RECNO);
        }
开发者ID:mcandre,项目名称:db,代码行数:27,代码来源:BTreeDatabase.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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