If you've been trying to figure out how to work with Cassandra then you've probably come across Thrift. Thrift is a library written in the spirit of Google's protocol buffers, but developed by Facebook and then open-sourced in 2007. The quick and short of it is that Thrift enables you to create RPC style calls in a platform-independent and XML-free way that is extremely efficient and surprisingly easy to work with once you get all the pieces working. Rich Atkinson already has a great blog post on how to get up and running with Thrift on Snow Leopard. So if that's what you're running, I'm going to suggest you check it out. If you're running Ubuntu you'll need to satisfy the following dependencies:and the source can be obtained with:and then you can proceed with the standard "configure && make && make install". Hopefully at this point you have the Thrift native libraries installed. Since this is about Ruby, you should also install the Thrift gem that will take advantage of the native libraries.Armed with both native library and gem, let's go ahead and navigate to your Cassandra install's interface directory (cassandra/interface) and build the ruby code:This will generate (as of this writing...) three files: gen-rb/cassandra.rb, gen-rb/cassandra_constants.rb, and gen-rb/cassandra_types.rb. At this point you can create a temp.rb file in the gen-rb folder to play around with connections. Here's a short example of how to make a GET request for a specific key: It's worth noting that there *is* a gem available on github from fauna/cassandra that creates a much easier-to-work-with client, but since the interface for Cassandra is still evolving and changing the client is broken at the moment. As far as I know this only applies to Cassandra 0.4.1 DEV and newer. I'm very much looking forward to a working update.
sudo aptitude -q -y install libexpat1-dev libboost1.37-dev g++ autoconf automake libtool
svn co http://svn.apache.org/repos/asf/incubator/thrift/trunk thrift
sudo gem install thrift
thrift --gen rb:new_style cassandra.thrift