views:

435

answers:

3

I guess the title says it all.

I am looking at whether Cassandra might be an option for a distributed database store for our server software.

The server software is written in Delphi, but I'm having difficulty locating descriptions of how to access a Cassandra database from Delphi.

Any help & suggestions welcome!

+2  A: 

One suggestion elsewhere on SO is to write your own Delphi generator for the Thrift framework.

Conor Boyd
I've been looking at the Thrift generator. It's definitely the 'best'/'most appropriate' option, but there are some issues: It's tricky to compile/run it on Windows. It's pretty complicated/dense code in terms of the source code generation aspects. Lack of generics in pre D2009 means two versions would need to be created (we are still using D2007 for a number of reasons).
Raymond Wilson
I located a copy of the C# generated code and related libraries from someone on the Cassandra user mailing list. I've used this code as a template to implement a relatively small proof-of-concept app in Delphi which can talk to a Cassandra node and perform insert() and get() operations. In reality, the boilerplate code is a little painful, but it's mostly a matter of copy/paste and tweak, so the time involved is not significant...
Raymond Wilson
+1  A: 

I see two options, either write your own native Delphi driver or use available drivers somehow.

One solution could be to use Python4Delphi to host Python inside Delphi application and use Python code to interface the Cassandra. A little bit clumsy and performance isn't probably the best possible.


Edit: Option #3: Write a proxy server with supported language, which offers interface for your Delphi application.

Harriv
The whole Cassandra - Thrift - Generated Clients relationships seem pretty confusing from the outside. I suspect a native Delphi driver that replaces the Thrift layer would be doable, though I need to research the Thrift API as used to talk to Cassandra...
Raymond Wilson
Basically you would need first to implement the Thrift RPC Protocol in Delphi, and then generate the API for Cassandra using Thrift. I would look if other solutions would have more easily implementable API first.
Harriv
Do you have particular suggestions for a Cassandra like index/value store with a simpler API?
Raymond Wilson
@Raymond Wilson: Not really, here's one list with API's: http://www.metabrew.com/article/anti-rdbms-a-list-of-distributed-key-value-stores/I would probably see if CouchDB fulfills the requirements. It has HTTP interface, so it's basically "universal" api.
Harriv
If you want a delphi-friendly nosql db, there are lots of easy options. FlashFiler comes to mind.
Warren P
I just played with it for the last hour or so, and I must say, for a "fast" replicatable no-SQL key-value-store (persistent) MemCacheDB rules. Wow. You could write a trivial Indy or ICS network component, use the simple memcache-style text protocol to implement GET/SET and have a networked high performance replicatable key-value store. Wow. It's memcache but with storage to disk. Great.
Warren P
I just read the description of the Delphi BigTable component. This is a very similar approach to our existing single node solution. It does not deal with multiple nodes/replication however. I'll take a look at MemCacheDB...
Raymond Wilson
A: 

Cassandra was written in Java, and is usually deployed on Linux systems (the term LAMP, refers to the stack of usual suspects; linux-apache-mysql-php). In this case, Cassandra would be a No-SQL bigtable alternative to something like MySql, and would be used by java-centric developers, so no PhP there. But you're still talking about the Unix/Linux world, whereas Delphi exists in the Windows world.

So, with Cassandra running on a Linux (web-server) box, how to access it from a Delphi app running windows box? The APIs are part of the facebook "Thrift" API. You could use a Python-Delphi integration module to load up the Python thrift APIs. Or you could write your own native pascal Thrift integration. I see problems with both approaches. For one thing, you would be on your own here, either way.

Looks like Cassandra can run on Windows (it is written in Java, so it better!), and a bat file is included to start it up on Windows, but the file layout is "more designed for Unix use", and it is used in deployment almost exclusively on Linux or Unix systems.

Warren P
I found http://developers.facebook.com/thrift/thrift-20070401.pdf, which seems to be a respectable discussion of how Thrift is implemented and which is the reference spec against which (I assume) all the other language implementations are coded. However, this does look like it might be a chunk of work if you have to build it from the ground up, or perhaps not - it's hard to tell!Cassandra directly
Raymond Wilson