New Cassandra 2.0 Release: Strengthen CQL, Support for Triggers, Lightweight Transactions and lots more...

Apache Cassandra gets a new release 2.0 on 4th September 2013. Being Developed at facebook and later open sourced, it is one of the most famous NoSQL databases used world wide. Based on Google's BigTable and Amazon's DynamoDB, it is highly scalable, distributed with no single point of failure.

With the new release of 2.0 a lots of additional features is being added to Cassandra. The most notable feature is the support for lighweight transactions, which guarantees that any one data store operations isn't interrupted by any other operation. In popular NoSQL databases Cassandra is first consistent database to implement lightweight transactions.

Again there has been a notable changes in the CQL too. Few are:

Alter Drop for Column Names

In Cassandra 1.2, CQL3 doesn't support dropping of Column Names from a table. But now that is fixed in Cassandra 2.0 For e.g
if we have:

create table tableName(
empId int PRIMARY KEY,
age int,
address text,
phone long
now we can do:  

alter table tableName drop phone;

This will drop the column name as well as all the data pertaining to the same in the column family. This data removal is however performed lazily during compaction (compaction simply looks for dropped columns in the input sstables and doesn’t include them in the output; note that if you want to force the removal of dropped columns without waiting for compactions to automatically kick in, you can simply callnodetool upgradesstables) and the ALTER TABLE statement (that simply updates the table metadata to register the drop) will return quickly.

Conditional schema modifications

Let say at the start of insertion code we don't have any idea about the table (or keyspace, or index) in the database, and it may be needed to get created, then we can use  IF in the schema modification statement (CREATE/DROP KEYSPACE/TABLE/INDEX) for the same. For e.g

               WITH replication = { 'class': 'SimpleStrategy',
                                    'replication_factor' : 3 };


Support for trigger

Cassandra 2.0 also introduces support for triggers to register a trigger on a table

                ON tableName
             USING 'org.apache.cassandra.triggers.InvertedIndex'

further we can drop it as:

DROP TRIGGER myTrigger ON myTable
where 'org.apache.cassandra.triggers.InvertedIndex' is the Java class implementing the trigger in this example

Secondary indexes on PRIMARY KEY columns

In Cassandra 2.0, we can create secondary indexes on CQL3 columns that are even part of the PRIMARY KEY definition

create table tableName(
empId int,
age int,
address text,
phone long
PRIMARY KEY ((empId ,age), phone)

Now we can create index on age as:

Create Index on tableName(age);

which was not available before Cassandra 2.0

Well these are a few notable modification and add-on that has been done in the newer version, there are also a few more. Will let you updated when i will go through it.

Find Comments below or Add one

Raman said...

Nice to Know Cassandra's new features. Thanx :)

Post a Comment