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)

https://c.statcounter.com/9397521/0/fe557aad/1/|stats

  • No labels