2011年12月25日 星期日

Road of Migration: From Traditional DB to Cassandra(1)

As using SQL-Supported DB always encounters the tragedy of performance issue. nosql DB becomes my next of my research milestone. While figuring why all the example code posted on internet does not work. I finally figure out that the supported JAVA api is quite different from 0.6.6 to 1.0.6.

The difference is mentioned here:

If you are new to Cassandra and just want to get started, take a look at the available clients ClientOptions (v0.6) instead.

This page shows examples of using the low-level Thrift interface, primarily intended for client library developers.

To generate the bindings for a particular language, first find out if Thrift supports that language. If it does, you can run "thrift --gen XYZ interface/cassandra.thrift" for whatever XYZ you fancy.

These examples are for Cassandra 0.5 and 0.6.

As of 0.7 and later, the default thrift transport is TFramedTransport so if you get an error such as "No more data to read", switch transports.


For insertion example:

Ver 0.6.6


public void insert(java.lang.String keyspace,
                   java.lang.String key,
                   ColumnPath column_path,
                   byte[] value,
                   long timestamp,
                   ConsistencyLevel consistency_level)
            throws InvalidRequestException,
                   UnavailableException,
                   TimedOutException,
                   org.apache.thrift.TException


Ver 1.0.6

public void insert(java.nio.ByteBuffer key,
                   ColumnParent column_parent,
                   Column column,
                   ConsistencyLevel consistency_level)
            throws InvalidRequestException,
                   UnavailableException,
                   TimedOutException,
                   org.apache.thrift.TException

沒有留言:

張貼留言