In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains how to install and use leveldb. Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install and use leveldb.
Brief introduction of leveldb installation and use of leveldb
Leveldb is a fast key-value pair storage database developed by Google with C++, providing sequential mapping from string keys to string values.
Leveldb installation downloads leveldbgit clone https://github.com/google/leveldb.git compiling leveldbcd leveldb/make
The compiled dynamic libraries and static libraries are respectively under out-shared,out-static:
Ls leveldb/out-shared/libleveldb.so.1.20ls leveldb/out-static/libleveldb.an install leveldb
Only dynamic libraries need to be installed, and static libraries can be linked directly when you compile
# cp leveldb header filesudo cp-r / leveldb/include/ / usr/include/# cp lib to / usr/lib/sudo cp / leveldb/out-shared/libleveldb.so.1.20 / usr/lib/# create linksudo ln-s / usr/lib/libleveldb.so.1.20 / usr/lib/libleveldb.so.1sudo ln-s / usr/lib/libleveldb.so.1.20 / usr/lib/libleveldb.so# update lib cachesudo ldconfig
Check to see if the installation is successful
Ls / usr/lib/libleveldb.so*# shows that the following three files are installed successfully / used by usr/lib/libleveldb.so.1.20/usr/lib/libleveldb.so.1/usr/lib/libleveldb.soleveldb
Let's write a hello_leveldb.cc to test our leveldb.
# include
# include
# include
# include
/ / include the necessary header files
# include
Using namespace std
Int main (void) {leveldb::DB * db = nullptr; leveldb::Options options; / / create the database options.create_if_missing = true; / / if the database does not exist in / tmp/testdb leveldb::Status status = leveldb::DB::Open (options, "/ tmp/testdb", & db); assert (status.ok ()); std::string key = "A" Std::string value = "a"; std::string get_value; / / write key1-> value1 leveldb::Status s = db- > Put (leveldb::WriteOptions (), key, value); / / read the value corresponding to key:people if the write is successful
If (s.ok ()) s = db- > Get (leveldb::ReadOptions (), "A", & get_value)
/ / output if (s.ok ()) if it is read successfully
Cout
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.