Giving KyotoCabinet a go

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 thoughts on “Giving KyotoCabinet a go”

  1. 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.

  2. Pingback: Performance Tests using python – Kyoto Cabinet – Ubuntu | NextDime Networks

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.