Differences between revisions 17 and 18
Revision 17 as of 2010-12-06 22:21:58
Size: 1641
Comment:
Revision 18 as of 2013-05-19 04:18:46
Size: 1525
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
The lowest-level official API for accessing Cassandra is that of the [[http://incubator.apache.org/thrift/|Thrift]] interface. This is primarily intended for client library developers; application developers are strongly advised to use a higher-level client as described in ClientOptions. The [[http://incubator.apache.org/thrift/|Thrift]] interface is a legacy API for [[ClientOptionsThrift|older clients]].
Line 3: Line 3:
Should you wish to use the Thrift API, see [[API]] for what data structures and method calls are available. If you are developing such a client with the Thrift API, see [[API]] for what data structures and method calls are available, and ThriftExamples for examples.
Line 5: Line 5:
The purpose of using Thrift in Cassandra is allow portable (across programming languages) access to the database. Thrift accomplishes this by generated source code for the programming language in question based on a Thrift IDL file describing the service (see [[https://svn.apache.org/repos/asf/cassandra/trunk/interface/cassandra.thrift|here]]). The purpose of using Thrift in Cassandra was to allow portable (across programming languages) access to the database. Thrift accomplishes this by generated source code for the programming language in question based on a Thrift IDL file describing the service (see [[https://svn.apache.org/repos/asf/cassandra/trunk/interface/cassandra.thrift|here]]).
Line 19: Line 19:

The Thrift interface is a legacy API for older clients.

If you are developing such a client with the Thrift API, see API for what data structures and method calls are available, and ThriftExamples for examples.

The purpose of using Thrift in Cassandra was to allow portable (across programming languages) access to the database. Thrift accomplishes this by generated source code for the programming language in question based on a Thrift IDL file describing the service (see here).

Let's see how we can use a generated python client to access Cassandra.

  1. Download Thrift and install it

  2. cd cassandra/interface
  3. thrift -gen py cassandra.thrift
  4. cd gen-py/cassandra

Run the script without arguments to get usage information:

Usage: ./Cassandra-remote [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]

Some examples of setting and getting values:

$ ./Cassandra-remote -h cass-1:9160 insert Keyspace1 eevans "ColumnPath('Standard1', column='fruit')" apple 1 ConsistencyLevel.QUORUM
None
$ ./Cassandra-remote -h cass-1:9160 get Keyspace1 eevans "ColumnPath('Standard1', column='fruit')" ConsistencyLevel.QUORUM
ColumnOrSuperColumn(column=Column(timestamp=1, name='fruit', value='apple'), super_column=None)

ThriftInterface (last edited 2013-11-15 18:11:52 by GehrigKunz)