How are static columns stored internally in cassandra? Can someone please post an example discussing the design implementation of static column in cassandra?
Asked
Active
Viewed 2,628 times
9
-
I have already searched over the internet for the documentation but cant find any details related to internal structure – Sachin Janani Feb 27 '15 at 22:03
1 Answers
19
Why don't we take a look at the structure of a table with static columns on disk and find out?
cqlsh:test> CREATE TABLE test (k int, v int, s int static, d int, PRIMARY KEY(k,v))
cqlsh:test> INSERT INTO test (k, v, s, d) VALUES ( 1, 1 ,20, 1 );
cqlsh:test> INSERT INTO test (k, v, s, d) VALUES ( 1, 3 ,21, 2 );
cqlsh:test> INSERT INTO test (k, v, s, d) VALUES ( 1, 2 ,21, 2 );
Exit out of C* and run nodetool flush
to make our sstables. Run sstable2json
on the .db file that was created in the data directory.
[
{"key": "1", <--- K=1 Partition
"cells": [[":s","21",1425050917842350], <---- Our Static Column
["1:","",1425050906896717], < --- C=1 row
["1:d","1",1425050906896717], < --- C=1, D=1 value
["2:","",1425050917842350], < --- C=2 row
["2:d","2",1425050917842350], < --- C=2, D=2 value
["3:","",1425050912874025], <--- C=3 Row
["3:d","2",1425050912874025]]} <--- C=3, D=2 Value
]
You can see that in Cassandra this static column is held in a cell with the title "Blank:ColumnName" at the very beginning of our partition. Unlike all the other cells there is no information about c(our clustering column) in the cell name, so all values of c will still modify the same static column s
For more details on why this is, check out the JIRA at https://issues.apache.org/jira/browse/CASSANDRA-6561 and the blog post at http://www.datastax.com/dev/blog/cql-in-2-0-6

RussS
- 16,476
- 1
- 34
- 62