Cassandra静态柱设计 [英] Cassandra Static Column design

查看:713
本文介绍了Cassandra静态柱设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Cassandra内部存储静态列?有人可以发表一个例子,讨论在cassandra中静态列的设计实现吗?

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

推荐答案

为什么不看看

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 );

退出C *并运行 nodetool flush 使我们的sstables。在数据目录中创建的.db文件上运行 sstable2json

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
]

您可以看到,在Cassandra中,这个静态列保存在一个单元格中,标题为Blank:ColumnName在分区的开头。与所有其他单元格不同,在单元名称中没有有关 c (我们的聚类列)的信息,因此 c 的所有值仍将修改相同的静态列

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

有关此原因的详细信息,请查看JIRA
https://issues.apache.org/jira/browse/CASSANDRA-6561
和博客帖子
http://www.datastax.com/dev/blog/cql-in-2-0-6

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

这篇关于Cassandra静态柱设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆