[Cassandra] static column

How are static columns stored internally in cassandra? Can someone please post an example discussing the design implementation of static column in cassandra?

 

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 cqlsh 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], < --- v=1 row
           ["1:d","1",1425050906896717], < --- v=1, d=1 value
           ["2:","",1425050917842350], < --- v=2 row
           ["2:d","2",1425050917842350], < --- v=2, d=2 value
           ["3:","",1425050912874025], <--- v=3 Row
           ["3:d","2",1425050912874025]]} <--- v=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

 

Reference: 

https://stackoverflow.com/questions/28767452/cassandra-static-column-design

http://www.datastax.com/dev/blog/cql-in-2-0-6

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值