Posts

Showing posts with the label cassandra query language

Cassandra Composite Types - A Overview [with CQL & Cassandra-Cli examples]

Just felt like sharing what is composite type in cassandra and How can we make use of it After so many discussions in Stackoverflow and PHPCassa forums, I hope I have got a clear picture over the topic What are composite types? Composite types are like structures in C or C++ For ex: The way we define a linked list [basic] struct LLNode { int data; char name[20]; struct LLNode *next; } Which means every member of this struct will have data of type int, name of type char array and a next pointer of type LLnode The struct is a composite of basic datatypes[not exactly in this case] Also you can't initialize value to any of these attributes when you define a struct The same way Cassandra Composite Type is a dataType derived from existing basic supported dataTypes . Why do we need this? Cassandra initially had and still has the concept of super columns. The basic use of them is maintaining an inverted index . Consider a data model in cassandra ColumnFamily: UserMast...

CQL(Cassandra Query Language) Reference

Hi, I think now I'm eligible to publish a blog post regd CQL. I wish this blog to be a tutorial rather a Syntax provider for various CQL queries Points to remember 1. CQL doesn't support Composite Types[likely to chage] 2. CQL doesn't support Super columns 3. Counter values are returned in native format [atleast in php/using cqlsh] Why should I prefer CQL? 1. Readability 2. Ease of use 3. SQL like 4. Stable Support: PHP => My Posts using PHPCassa Python => Refer Here and Download it here Java => JDBC Driver and Example is here Ruby => This might help Creating a Keyspace: cqlsh> CREATE KEYSPACE sample WITH strategy_class = 'org.apache.cassandra.locator.SimpleStrategy' ... AND strategy_options:replication_factor = 2; Note: : => Option Specifier Use a Keyspace: cqlsh> USE sample; Note: Don't forget to USE before use 'Sample' and 'sample' are different. Create Column Family: cqlsh...