In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use the C # Berkeley DB database, which is very detailed and has a certain reference value. Interested friends must finish reading it!
Berkeley DB is an embedded database system with a long history, which is mainly used in UNIX/LINUX operating system. Berkeley DB stores key/value key-value pairs, which can be understood as super hash tables on the hard disk. It can manage 256TB data and can support thousands of concurrent accesses. At present, Berkeley DB is available in C++ and Java. So, we need an intermediate transformation for access, and someone has already released the API of C#. It can be found on Berkeley DB for .NET, and now the * * version is 0.95 and can support version 4.3 and 4.5. This article will take version 4.5 as an example.
After you download it to the API--libdb-dotnet_0_95.zip of Berkeley DB for .net, you can start using it. First find libdb_dotNET45.dll in the bin directory unzipped by libdb-dotnet_0_95.zip, which is the dll used in version 4.5. Create a new project and reference the dll. Note that the source code may be compiled by yourself, but it is mainly due to the inconsistent visibility of some delegates and delegates. Just change the class or struct used in those parameters to public.
C # Berkeley DB database operations require the help of the DbBTree class. So you need to get an instance of DbBTree first, but the DbBTree class will be dependent on several other classes and must rely on several other classes to create.
The following code is a process of initializing the DbBTree instance.
/ Database directory / private string directory; / Database filename / private string dbName; private DbBTree btree; private Txn txn; private Db db; private Env env; / initialize / private void Init () {env = new Env (EnvCreateFlags.None) Env.OpenFlags envFlags = Env.OpenFlags.Create | Env.OpenFlags.InitLock | Env.OpenFlags.InitLog | Env.OpenFlags.InitMPool | Env.OpenFlags.InitTxn | Env.OpenFlags.Recover; env.Open (directory, envFlags, 0); txn = env.TxnBegin (null, Txn.BeginFlags.None); db = env.CreateDatabase (DbCreateFlags.None); btree = (DbBTree) db.Open (txn, dbName, null, DbType.BTree, Db.OpenFlags.Create, 0);}
In addition, the operation of C # Berkeley DB database needs the help of serialization.
/ binary serialization / privateBinaryFormatterformatter; / key memory stream / privateMemoryStreamkeyStream; / content memory stream / privateMemoryStreamdataStream; privatevoidStreamInit () {formatter=newBinaryFormatter (); keyStream=newMemoryStream (); dataStream=newMemoryStream ();}
Key value C # Berkeley DB database, so define an interface to get the key:
PublicinterfaceIPut {stringKey {get;}} these are all the contents of the article "how to use C # Berkeley DB Database". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.