Giving KyotoCabinet a go

Install KC:

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:

tar xzvf kyotocabinet-python-legacy-1.18.tar.gz 
cd kyotocabinet-python-legacy-1.18
python 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"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
    print >>sys.stderr, "get error: " + str(db.error())
# traverse records
cur = db.cursor()
while True:
    rec = cur.get(True)
    if not rec: break
    print rec[0] + ":" + rec[1]
# 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 implementation


Working with spatial data


4 thoughts on “Giving KyotoCabinet a go”

  1. Good instructions but I get:
    ImportError: 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.