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

C# BerkeleyDB.DatabaseEntry类代码示例

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

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



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


示例16: LoadInventoryDB

        public void LoadInventoryDB(string dataDir)
        {
            DatabaseEntry key, data;
            string inventory_text_file = dataDir + "\\" + "inventory.txt";

            if (!File.Exists(inventory_text_file)) {
                Console.WriteLine("{0} does not exist.", inventory_text_file);
                return;
            }

            using (StreamReader sr = File.OpenText(inventory_text_file)) {
                Inventory inventory = new Inventory();
                string input;

                /* Text file fields are delimited by #, just read them in. */
                while ((input=sr.ReadLine())!=null) {
                    char [] delimiterPound = {'#'};
                    string [] fields = input.Split(delimiterPound);
            #if TEST_DEBUG
                    System.Console.WriteLine(input);
            #endif
                    inventory.Itemname = fields[0];
                    inventory.Sku = fields[1];
                    inventory.Price = float.Parse(fields[2]);
                    inventory.Quantity = int.Parse(fields[3]);
                    inventory.Category = fields[4];
                    inventory.Vendor = fields[5];

                    /* Insert key/data pairs into database. */
                    key = new DatabaseEntry();
                    key.Data = System.Text.Encoding.ASCII.GetBytes(
                        inventory.Sku);

                    byte [] bytes = inventory.getBytes();
                    data = new DatabaseEntry(bytes);

                    try {
                        myDbs.InventoryDB.Put(key, data);
                    } catch(Exception e) {
                        Console.WriteLine("LoadInventoryDB Error.");
                        Console.WriteLine(e.Message);
                        throw e;
                    }
                }
            }
        }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:46,代码来源:DatabaseLoader.cs


示例17: showItem

        public void showItem(string locateItem)
        {
            SecondaryCursor secCursor;

            /* searchKey is the key to find in the secondary db. */
            DatabaseEntry searchKey = new DatabaseEntry();
            searchKey.Data = System.Text.Encoding.ASCII.GetBytes(locateItem);

            /* Open a secondary cursor. */
            secCursor = this.myDbs.ItemSecbtreeDB.SecondaryCursor();

            /*
             * Search for the secondary. The primary key/data pair
             * associated with the given secondary key is stored in Current.
             * In the presence of duplicate key values, the first data
             * item in the set of duplicates is stored in Current.
             */
            if (secCursor.Move(searchKey, true)) {
                Inventory theInventory = new Inventory(
                    secCursor.Current.Value.Value.Data);

                /* Display the record. */
                displayInventory(theInventory);

                /* Get each duplicate. */
                while (secCursor.MoveNextDuplicate()) {
                    theInventory = new Inventory(
                        secCursor.Current.Value.Value.Data);
                    displayInventory(theInventory);
                }
            } else {
                Console.WriteLine("Could not find itemname {0} ", locateItem);
                Console.WriteLine();
                Console.WriteLine();
                return;
            }

            /* Close the cursor and the duplicate cursor. */
            secCursor.Close();
        }
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:40,代码来源:DatabaseReader.cs


示例18: GetNextDBEntry

        static public DatabaseEntry GetNextDBEntry(DatabaseEntry key)
        {

            long FirstPart;
            if (key.Data != null)
            {
                using (var ms = new MemoryStream(key.Data))
                {
                    using (var bw = new BinaryReader(ms))
                    {
                        FirstPart = bw.ReadInt64();
                        bw.Close();
                    }
                    ms.Close();
                }
            }
            else
            {
                FirstPart = 0;
            }
            int count = sizeof(long) + sizeof(byte) + sizeof(byte);
            var data = new byte[count];

            using (var ms = new MemoryStream(data))
            {
                using (var bw = new BinaryWriter(ms))
                {
                    bw.Write((FirstPart+1));
                    bw.Write((byte)0);
                    bw.Write((byte)0);
                    bw.Close();
                }
                ms.Close();
            }
            return new DatabaseEntry(data);

        }
开发者ID:SoftFx,项目名称:PerformancePoC,代码行数:37,代码来源:BdbPerformTest.cs


示例19: Put

 /// <summary>
 /// Store the key/data pair in the database, replacing any previously
 /// existing key if duplicates are disallowed, or adding a duplicate
 /// data item if duplicates are allowed.
 /// </summary>
 /// <overloads>
 /// <para>
 /// If the database supports duplicates, add the new data value at the
 /// end of the duplicate set. If the database supports sorted
 /// duplicates, the new data value is inserted at the correct sorted
 /// location.
 /// </para>
 /// </overloads>
 /// <param name="key">The key to store in the database</param>
 /// <param name="data">The data item to store in the database</param>
 /// <exception cref="DatabaseException">
 /// Partial put to a duplicate database, or <see cref="QueueDatabase"/>
 /// or <see cref="RecnoDatabase"/> with fixed-length records.
 /// </exception>
 public void Put(DatabaseEntry key, DatabaseEntry data)
 {
     Put(key, data, null);
 }
开发者ID:simonzhangsm,项目名称:h-store,代码行数:23,代码来源:Database.cs


示例20: GetMultiple

        /// <summary>
        /// Retrieve a key and all duplicate data items from the database.
        /// </summary>
        /// <param name="key">The key 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>
        /// <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> GetMultiple(
            DatabaseEntry key,
            int BufferSize, Transaction txn, LockingInfo info)
        {
            KeyValuePair<DatabaseEntry, DatabaseEntry> kvp;

            DatabaseEntry data = new DatabaseEntry();
            for (; ; ) {
                data.UserData = new byte[BufferSize];
                try {
                    kvp = Get(key, data, txn, info, DbConstants.DB_MULTIPLE);
                    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,代码行数:45,代码来源:Database.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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