This project is read-only.

Need some help

Mar 12, 2012 at 1:13 PM
Edited Mar 12, 2012 at 1:16 PM


I found your version of cassandra client much updated and still working with cassandra 1.0

I am new to the client and cassandra as well. I needed some guidance in creating the following. This might not be a particular issue but I need some help. I am new to the syntax.

Thank you

TagNo // This is the super column
  ID // This is the column family
     // here we shall have lots of entries. (Rows)
     user1: {rate, distance, capacity}
     user2: {rate, distance, capacity}

Rate distance and capacity can be stored as either strings or doubles. But does not really matter at the moment.

I need to know what would be the code snippet to do so if I am using a keyspace "Test".

Thank you.

Mar 12, 2012 at 7:15 PM

Following code is query sample.

You can get more sample in document page.


using(var context = new CassandraContext("localhost", 9160, "Test"))
    var entitys = from x in context.SuperColumn
                    where x.Key == "user1" &&
                    x.ColumnFamily == "ID" &&
                    x.SuperColumn == "TagNo"
              select x;
    foreach(CassandraEntity<SuperColumn> e in entitys)
        // rate

        // distance

        // capacity

Mar 13, 2012 at 8:25 AM

Thank you for the code!!

Mar 13, 2012 at 11:46 AM


I created another keyspace with the following over cassandra-CLI

create keyspace Stacks with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' and strategy_options = {replication_factor:1};

create column family StackID with column_type = 'Super' and comparator = 'UTF8Type' and subcomparator = 'UTF8Type' and default_validation_class = 'UTF8Type' and column_metadata =

[{ column_name : 'Initial', validation_class : UTF8Type}, {column_name : 'Last', validation_class : UTF8Type}];

Now when I try to query the data using one of the operations I keep getting exception.

Probably I am not doing it properly.

var entitys = from x in context.SuperColumn
                    where x.Key == "Initial" &&
                    x.ColumnKey == "Initial" &&
                    x.SuperColumn == "StackID"
              select x;

In 'Results View' after a debug point in entitys I get

base {System.SystemException} = {"You can't specify Column in case of get SuperColumn."}

What am I doing wrong here?

Mar 14, 2012 at 1:40 AM

You should replace SuperColumn to Column.

var entitys = from x in context.SuperColumn
                    where x.Key == "Initial" &&
                    x.ColumnKey == "Initial" &&
                    x.Column == "StackID"
              select x;

Because SuperColumn mean ColumnPath.SuperColumn.

In case get operation for SuperColumnFamily, We should specify ColumnPath.Column = 'SuperColumnName'.

Mar 14, 2012 at 6:18 AM

OK here is how I did it

var entitys = from x in context.Column
                    where x.Key == "Initial" &&
                    x.ColumnFamily == "StackID"
              select x;