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


C# BerkeleyDB.DatabaseEntry类代码示例

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


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

示例1: SecondaryKeyGen

        public DatabaseEntry SecondaryKeyGen(
		    DatabaseEntry key, DatabaseEntry data)
        {
            DatabaseEntry dbtGen;
            dbtGen = new DatabaseEntry(data.Data);
            return dbtGen;
        }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:7,代码来源:SecondaryBTreeDatabaseTest.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: CheckPartial

        public void CheckPartial(
		    DatabaseEntry key, uint kOffset, uint kLen,
		    DatabaseEntry pkey, uint pkOffset, uint pkLen,
		    DatabaseEntry data, uint dOffset, uint dLen)
        {
            if (key != null) {
                Assert.IsTrue(key.Partial);
                Assert.AreEqual(kOffset, key.PartialOffset);
                Assert.AreEqual(kLen, key.PartialLen);
                Assert.AreEqual(kLen, (uint)key.Data.Length);
            }

            if (pkey != null) {
                Assert.IsTrue(pkey.Partial);
                Assert.AreEqual(pkOffset, pkey.PartialOffset);
                Assert.AreEqual(pkLen, pkey.PartialLen);
                Assert.AreEqual(pkLen, (uint)pkey.Data.Length);
            }

            if (data != null) {
                Assert.IsTrue(data.Partial);
                Assert.AreEqual(dOffset, data.PartialOffset);
                Assert.AreEqual(dLen, data.PartialLen);
                Assert.AreEqual(dLen, (uint)data.Data.Length);
            }
        }
开发者ID:mcandre,项目名称:db,代码行数:26,代码来源:SecondaryCursorTest.cs

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

示例5: Set

        public void Set(DatabaseEntry key, DatabaseEntry value, bool flush = false)
        {
            _btreeDb.Put(key, value);

            if (flush)
                _btreeDb.Sync();
        }
开发者ID:SoftFx,项目名称:PerformancePoC,代码行数:7,代码来源:BdbStorage.cs

示例6: SendMessage

 /// <summary>
 /// Send a message on the message channel. The message is sent 
 /// asynchronously. The method does not wait for a response before
 /// returning. It usually completes quickly because it only waits for
 /// local TCP implementation to accept the bytes into its network data 
 /// buffer. However, this message could block briefly for longer
 /// messages, and/or if the network data buffer is nearly full. 
 /// It could even block indefinitely if the remote site is slow
 /// to read.
 /// </summary>
 /// <remarks>
 /// <para>
 /// To block while waiting for a response from a remote site, use 
 /// <see cref="SendRequest"/> instead of this method.
 /// </para>
 /// <para>
 /// The sent message is received and handled at remote sites using a
 /// message dispatch callback, which is configured using
 /// <see cref="DatabaseEnvironment.RepMessageDispatch"/>. This
 /// method may be used within the message dispatch callback on the
 /// remote site to send a reply or acknowledgement for messages that it
 /// receives and is handling.
 /// </para>
 /// <para>
 /// This method may be used on channels opened to any destination. See
 /// <see cref="DatabaseEnvironment.RepMgrChannel"/> for a list of 
 /// potential destinations.
 /// </para>
 /// </remarks>
 /// <param name="msg">
 /// An array of DatabaseEntry objects. Any flags for the DatabaseEntry
 /// objects are ignored.
 /// </param>
 public void SendMessage(DatabaseEntry[] msg) {
     int size = msg.Length;
     IntPtr[] dbts = new IntPtr[size];
     for (int i = 0; i < size; i++)
         dbts[i] = DBT.getCPtr(DatabaseEntry.getDBT(msg[i])).Handle;
     channel.send_msg(dbts, (uint)size, 0); 
 }
开发者ID:rohitlodha,项目名称:DenverDB,代码行数:40,代码来源:DbChannel.cs

示例7: KeyGenOnLittleByte

        public DatabaseEntry KeyGenOnLittleByte(
		    DatabaseEntry key, DatabaseEntry data)
        {
            byte[] byteArr = new byte[1];
            byteArr[0] = data.Data[0];
            DatabaseEntry dbtGen = new DatabaseEntry(byteArr);
            return dbtGen;
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:8,代码来源:JoinCursorTest.cs

示例8: KeyGenOnBigByte

        public DatabaseEntry KeyGenOnBigByte(
		    DatabaseEntry key, DatabaseEntry data)
        {
            byte[] byteArr = new byte[1];
            byteArr[0] = data.Data[data.Data.Length - 1];
            DatabaseEntry dbtGen = new DatabaseEntry(byteArr);
            return dbtGen;
        }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:8,代码来源:JoinCursorTest.cs

示例9: SecondaryEntryComparison

        public int SecondaryEntryComparison(
		    DatabaseEntry dbt1, DatabaseEntry dbt2)
        {
            int a, b;
            a = BitConverter.ToInt32(dbt1.Data, 0);
            b = BitConverter.ToInt32(dbt2.Data, 0);
            return a - b;
        }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:8,代码来源:SecondaryBTreeDatabaseTest.cs

示例10: AddOneByCursor

 public void AddOneByCursor(HashCursor cursor)
 {
     DatabaseEntry key, data;
     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);
     cursor.Add(pair);
 }
开发者ID:sukantoguha,项目名称:INET-Vagrant-Demos,代码行数:9,代码来源:HashCursorTest.cs

示例11: MultipleKeyGen

 public DatabaseEntry MultipleKeyGen(DatabaseEntry key, DatabaseEntry data)
 {
     LinkedList<DatabaseEntry> skeys = new LinkedList<DatabaseEntry>();
     String dataStr = Configuration.strFromDBT(data);
     foreach (String s in dataStr.Split(',')) {
         DatabaseEntry tmp = new DatabaseEntry();
         Configuration.dbtFromString(tmp, s);
         skeys.AddLast(tmp);
     }
     return new MultipleDatabaseEntry(skeys, false);
 }
开发者ID:xiaogao0371,项目名称:dockerfile,代码行数:11,代码来源:SecondaryDatabaseTest.cs

示例12: SecondaryKeyGen

        public DatabaseEntry SecondaryKeyGen(
            DatabaseEntry key, DatabaseEntry data)
        {
            DatabaseEntry dbtGen;

            int skey = BitConverter.ToInt32(data.Data, 0);
            // don't index secondary key of 0
            if (skey == 0)
                return null;

            dbtGen = new DatabaseEntry(data.Data);
            return dbtGen;
        }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:13,代码来源:ForeignKeyTest.cs

示例13: AddOneByCursor

        public static void AddOneByCursor(Database db, Cursor cursor)
        {
            DatabaseEntry key, data;
            KeyValuePair<DatabaseEntry, DatabaseEntry> pair;

            // Add a record to db via cursor.
            key = new DatabaseEntry(ASCIIEncoding.ASCII.GetBytes("key"));
            data = new DatabaseEntry(ASCIIEncoding.ASCII.GetBytes("data"));
            pair = new KeyValuePair<DatabaseEntry,DatabaseEntry>(key, data);
            cursor.Add(pair);

            // Confirm that the record has been put to the database.
            Assert.IsTrue(db.Exists(key));
        }
开发者ID:gildafnai82,项目名称:craq,代码行数:14,代码来源:CursorTest.cs

示例14: MoveToPos

        public void MoveToPos(string dbFileName, 
		    string dbSecFileName, bool ifPair)
        {
            // Open a primary database and its secondary database.
            BTreeDatabase db;
            SecondaryBTreeDatabase secDB;
            OpenSecDB(dbFileName, dbSecFileName, out db,
                out secDB);

            // Write ten records into the database.
            WriteRecords(db);

            SecondaryCursor secCursor = secDB.SecondaryCursor();
            DatabaseEntry key = new DatabaseEntry(
                BitConverter.GetBytes((int)0));
            DatabaseEntry notExistingKey = new DatabaseEntry(
                BitConverter.GetBytes((int)100));
            if (ifPair == false)
            {
                Assert.IsTrue(secCursor.Move(key, true));
                Assert.IsFalse(secCursor.Move(notExistingKey, true));
            }
            else
            {
                KeyValuePair<DatabaseEntry, KeyValuePair<
                    DatabaseEntry, DatabaseEntry>> pair =
                    new KeyValuePair<DatabaseEntry,
                    KeyValuePair<DatabaseEntry, DatabaseEntry>>(key,
                    new KeyValuePair<DatabaseEntry, DatabaseEntry>(
                    key, key));

                KeyValuePair<DatabaseEntry, KeyValuePair<
                    DatabaseEntry, DatabaseEntry>> notExistingPair;

                notExistingPair = new KeyValuePair<DatabaseEntry,
                    KeyValuePair<DatabaseEntry, DatabaseEntry>>(
                    notExistingKey, new KeyValuePair<
                    DatabaseEntry, DatabaseEntry>(
                    notExistingKey, notExistingKey));
                Assert.IsTrue(secCursor.Move(pair, true));
                Assert.IsFalse(secCursor.Move(notExistingPair, true));
            }

            secCursor.Close();
            secDB.Close();
            db.Close();
        }
开发者ID:sukantoguha,项目名称:INET-Vagrant-Demos,代码行数:47,代码来源:SecondaryCursorTest.cs

示例15: Main

        static void Main( string[] args )
        {
            try {
                var cfg = new HashDatabaseConfig();
                cfg.Duplicates = DuplicatesPolicy.UNSORTED;
                cfg.Creation = CreatePolicy.IF_NEEDED;
                cfg.CacheSize = new CacheInfo( 0, 64 * 1024, 1 );
                cfg.PageSize = 8 * 1024;

                Database db = HashDatabase.Open( "d:\\test.db", "hat_db", cfg );

                Console.WriteLine("db opened");

                var key = new DatabaseEntry();
                var data = new DatabaseEntry();

                key.Data = System.Text.Encoding.ASCII.GetBytes("key1");
                data.Data = System.Text.Encoding.ASCII.GetBytes("val1");

                try {
                    db.Put( key, data );
                    db.Put( key, data );
                }
                catch ( Exception ex ) {
                    Console.WriteLine( ex.Message );
                }

                using ( var dbc = db.Cursor() ) {

                    System.Text.ASCIIEncoding decode = new ASCIIEncoding();

                    /* Walk through the database and print out key/data pairs. */
                    Console.WriteLine( "All key : data pairs:" );
                    foreach ( KeyValuePair<DatabaseEntry, DatabaseEntry> p in dbc )
                        Console.WriteLine( "{0}::{1}",
                            decode.GetString( p.Key.Data ), decode.GetString( p.Value.Data ) );
                }

                db.Close();
                Console.WriteLine( "db closed" );
            }
            catch ( Exception ex ) {
                Console.WriteLine( ex.Message );
            }

            Console.ReadLine();
        }
开发者ID:borntolead,项目名称:a2hat,代码行数:47,代码来源:Program.cs


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