In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to mount LevelDB storage with KyotoTycoon". In daily operation, I believe many people have doubts about how to mount LevelDB storage with KyotoTycoon. The editor consulted all kinds of data and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "how to mount LevelDB storage with KyotoTycoon"! Next, please follow the editor to study!
1. Install LevelDB
Get the source code first
$svncheckout http://leveldb.googlecode.com/svn/trunk/leveldb-read-only
Modify Makefile and add the-fPIC option
+ CFLAGS=-c-I.-I./include$ (PLATFORM_CFLAGS) $(OPT)
-CFLAGS=-c-I.-I./include$ (PLATFORM_CFLAGS) $(OPT)-fPIC
If you are using Ubuntu, then modify the port/port_posix.h file:
+ # include
-# include
After the above modifications, start the installation
$make
$sudocplibleveldb.a/usr/local/lib
$sudocp-rinclude/leveldb/usr/local/include
In this way, LevelDB is installed.
two。 Mount LevelDB on KC
Download the latest KC source code and run the following command to install
$cdkyototycoon-x.y.z
$. / configure
$make
$sudomakeinstall
$cdlab/leveldb
$make
$sudocpktplugdblevel.so/usr/local/lib
After the installation is complete, it can be run.
$ktserver-pldb/usr/local/lib/ktplugdblevel.socasket.ldb
You can directly connect to some Set operations.
$ktremotemgrsetjapantokyo
$ktremotemgrsetkoreaseoul
$ktremotemgrsetchinabeijing
Check the data just entered by Set:
$ktremotemgrlist-pv
How to mount LevelDB storage with KyotoTycoon
3. Plug-in implementation
A copy of the source code attached to LevelDB is attached below, and the logic is very simple:
ClassLevelDB:publickt::PluggableDB {
...
Boolaccept_impl (constchar*kbuf,size_tksiz,Visitor*visitor,boolwritable) {
Size_tlidx=kc::hashmurmur (kbuf,ksiz)% RLOCKSLOT
If (writable) {
Rlock_.lock_writer (lidx)
} else {
Rlock_.lock_reader (lidx)
}
Std::stringkey (kbuf,ksiz)
Std::stringvalue
Lv::Statusstatus=db_- > Get (lv::ReadOptions (), key,&value)
Constchar*rbuf
Size_trsiz
If (status.ok ()) {
Rbuf=visitor- > visit_full (kbuf,ksiz,value.data (), value.size (), & rsiz)
} else {
Rbuf=visitor- > visit_empty (kbuf,ksiz,&rsiz)
}
Boolerr=false
If (rbuf==kc::BasicDB::Visitor::REMOVE) {
Lv::WriteOptionswopts
If (autosync_) wopts.sync=true
Status=db_- > Delete (wopts,key)
If (! status.ok ()) {
Set_error (_ KCCODELINE_,Error::SYSTEM, "DB::Deletefailed")
Err=true
}
} elseif (rbufo _ blank _ blank _ k _ c _ (C _ C _ V _ C _ G _ C _ V _ C _ G _ C _ V _ D _ R _ P
Lv::WriteOptionswopts
If (autosync_) wopts.sync=true
Std::stringrvalue (rbuf,rsiz)
Status=db_- > Put (wopts,key,rvalue)
If (! status.ok ()) {
Set_error (_ KCCODELINE_,Error::SYSTEM, "DB::Putfailed")
Err=true
}
}
Rlock_.unlock (lidx)
Return!err
}
...
}
At this point, the study on "how to mount LevelDB storage with KyotoTycoon" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.