Install KC:
wget http://fallabs.com/kyotocabinet/pkg/kyotocabinet-1.2.76.tar.gz
tar xzvf kyotocabinet-1.2.76.tar.gz
cd kyotocabinet-1.2.76
./configure && make && make install # takes a couple of minutes
Install Python binding:
wget http://fallabs.com/kyotocabinet/pythonlegacypkg/kyotocabinet-python-legacy-1.18.tar.gz
tar xzvf kyotocabinet-python-legacy-1.18.tar.gz
cd kyotocabinet-python-legacy-1.18
python setup.py install
Next, go nuts with the Python 2.x Documentation… and try the Hello world:
from kyotocabinet import *
import sys
# create the database object
db = DB()
# open the database
if not db.open("casket.kch", DB.OWRITER | DB.OCREATE):
print >>sys.stderr, "open error: " + str(db.error())
# store records
if not db.set("foo", "hop") or not db.set("bar", "step") or not db.set("baz", "jump"):
print >>sys.stderr, "set error: " + str(db.error())
# retrieve records
value = db.get("foo")
if value:
print value
else:
print >>sys.stderr, "get error: " + str(db.error())
# traverse records
cur = db.cursor()
cur.jump()
while True:
rec = cur.get(True)
if not rec: break
print rec[0] + ":" + rec[1]
cur.disable()
# close the database
if not db.close():
print >>sys.stderr, "close error: " + str(db.error())
That’s it. In my opinion, everything worked really well from an install perspective. I was up and running in minutes. Next thing is to understand 1) The API 2) The implementation 3) How to work with spatial data (probably the usual space-filling curve spiel).
The API
TODO
The implementation
TODO
Working with spatial data
TODO
4 responses to “Giving KyotoCabinet a go”
Good instructions but I get:
ImportError: libkyotocabinet.so.16: cannot open shared object file: No such file or directory
When I try to run your test program.
You need to make sure you have C++ and zlib! Not as daft as it sounds; Centos 6 minimal don’t have these installed.
yum -y install gcc-c++
yum -y install zlib-devel
wget http://fallabs.com/kyotocabinet/pkg/kyotocabinet-1.2.76.tar.gz
tar xzvf kyotocabinet-1.2.76.tar.gz
cd kyotocabinet-1.2.76
./configure && make && make install # takes some time!
Test Kyoto Cabinet with:
kcprototest wicked 5
This is important to make K.C. available outside root. Create a new file:
vi /etc/ld.so.conf.d/usrlocal.conf
and add the line
/usr/local/lib
Then run
ldconfig -v
[…] 2. http://skipperkongen.dk/2013/02/14/giving-kyotocabinet-a-go/ […]