I'm trying to understand why I'm seeing different data in two ways to display Cassandra (1.2.x) column family columns.
In the first, I use cassandra-cli
to list
the rows in a column family.
[cassandra-cli]> list Users columns 1;
Using default limit of 100
-------------------
RowKey: [rowkey1]
=> (name=[name1], value=[value1], timestamp=[timestamp1])
The data between []
is a placeholder for the value. In reality, they are displayed as the hex representation of a byte[]
. The above seems to indicate there is one row with a single column (which has a name, a value, and a timestamp).
I'm doing what I think is equivalent with the DataStax v1 API
var cluster = Cluster.Builder ()
.AddContactPoint ("127.0.0.1")
.Build ();
var metadata = cluster.Metadata;
var keyspace = "keyspaceName";
var tableMetadatas = metadata.GetTables(keyspace);
foreach (var tableMetadata in tableMetadatas) {
var session = cluster.Connect(keyspace);
var rowSet = session.Execute("SELECT * FROM \""+ tableMetadata + "\" ", ConsistencyLevel.One);
CqlColumn[] columns = rowSet.Columns;
foreach(var column in columns) {
Console.WriteLine("Column name: " + column.Name + ", type: " + column.Type + ", keyspace: " + column.Keyspace);
}
foreach (var row in rowSet.GetRows()) {
for (int i = 0; i < row.Length; i++) {
String value = Encoding.UTF8.GetString(row.GetValue<byte[]>(i));
Console.WriteLine(value);
}
}
}
This displays
Column name: key, type: System.Byte[], keyspace: keyspaceName
Column name: column1, type: System.Byte[], keyspace: keyspaceName
Column name: value, type: System.Byte[], keyspace: keyspaceName
[The string value of rowkey1]
[The string value of name1]
[The string value of value1]
This seems to indicate there are 3 columns: one with name key
, where the value is the rowkey
; one with name column1
, where the value is the value of name1
; and one with name value
, where the value is the value of value1
.
How should I be interpreting these discrepancies?
When using cassandra-cli
you are seeing a "Thrift-perspective" of your storage, while using the DataStax driver and cqlsh
will give you the "CQL-perspective".
There was a series of posts describing how these 2 are related. I've linked to these in my answer to the Different between Thrift and CQL3 columns question on SO.