====15 Feb 2012, by Bright Zheng (IT进行时)====
3. Core Concepts
3.1.
Keyspace
3.1.1. Intro
A keyspace is the first dimension of the Cassandra
hash, and is the container for the ColumnFamilies. Keyspaces are of roughly the
same granularity as a schema or database (i.e. a logical collection of tables)
in the RDBMS world. They are the configuration and management point for column
families, and is also the structure on which batch inserts are applied. In most
cases you will have one Keyspace for an application.
3.1.2. CLI
[default@unknown] drop keyspace Tutorial;
876ee520-571f-11e1-0000-242d50cf1ffd
Waiting for schema agreement...
... schemas agree across the cluster
[default@unknown] create keyspace Tutorial
... with strategy_options =
[{replication_factor:1}]
... and placement_strategy =
'org.apache.cassandra.locator.SimpleStrategy';
WARNING: [{}] strategy_options syntax is
deprecated, please use {}
8daea060-571f-11e1-0000-242d50cf1ffd
Waiting for schema agreement...
... schemas agree across the cluster
[default@unknown] use Tutorial;
Authenticated to keyspace: Tutorial
[default@Tutorial]
|
3.2. Column Family
3.2.1. Intro
A column family is a container for columns, something
like the TABLE in a relational system.
Model representation:
ColumnFamily
|
key
|
list
|
binary
|
1 .. * Columns
|
Data representation:
ColumnFamily
|
key
|
Columns
|
1
|
name
|
value
|
timestamp
|
|
"firstname"
|
"Ronald"
|
1270073054
|
|
"lastname"
|
"Mathies"
|
1270073054
|
|
"birthday"
|
"01/01/1978"
|
1270073054
|
2
|
name
|
value
|
timestamp
|
|
"firstname"
|
"John"
|
1270084021
|
|
"lastname"
|
"Steward"
|
1270084021
|
|
"birthday"
|
"01/01/1982"
|
1270084021
|
3.2.2. CLI
[default@Tutorial] drop column family StateCity;
StateCity not found in current keyspace.
[default@Tutorial] create column family StateCity
... with comparator = LongType
... and default_validation_class =
'UTF8Type'
... and key_validation_class =
'UTF8Type';
d3cfa8f0-571f-11e1-0000-242d50cf1ffd
Waiting for schema agreement...
... schemas agree across the cluster
[default@Tutorial]
|
Where:
1. Comparator
is used to validate and compare/sort Column names in the CF. It has following
supported types:
Type
|
Description
|
BytesType
|
Simple non-validating byte comparison (Default)
|
AsciiType
|
Similar to BytesType, but validates that input is US-ASCII
|
UTF8Type
|
UTF-8 encoded string comparison
|
LongType
|
Compares values as 64 bit longs
|
LexicalUUIDType
|
128 bit UUID compared by byte value
|
TimeUUIDType
|
Timestamp compared 128 bit version 1 UUID
|
Note:
- The above types are changeable subject to different versions.
- It is also valid to specify the fully-qualified class name to a customized
class that extends org.apache.Cassandra.db.marshal.AbstractType.
3.3. Column
3.3.1. Intro
A Column consists of a name, value and a timestamp.
Model representation:
Column
|
name
|
Binary
|
value
|
Binary
|
timestamp
|
i64
|
Data representation:
Column
|
name
|
value
|
timestamp
|
"firstname"
|
"Ronald"
|
1270073054
|
3.3.2. CLI
N/A
3.4. SuperColumn
3.4.1. Intro
A SuperColumn is very similar to a ColumnFamily, it
consists of a key and a list of Columns.
Model representation:
SuperColumn
|
key
|
list
|
binary
|
1 .. * Columns
|
Data representation:
SuperColumn
|
key
|
Columns
|
1
|
name
|
value
|
timestamp
|
|
"firstname"
|
"Ronald"
|
1270073054
|
|
"lastname"
|
"Mathies"
|
1270073054
|
|
"birthday"
|
"01/01/1978"
|
1270073054
|
2
|
name
|
value
|
timestamp
|
|
"firstname"
|
"John"
|
1270084021
|
|
"lastname"
|
"Steward"
|
1270084021
|
|
"birthday"
|
"01/01/1982"
|
1270084021
|
The only difference to ColumnFamily is the usage. A
SuperColumn is used within a ColumnFamily. So it adds an extra layer in your
data structure, instead of having only a row which consists of a key and a list
of columns. We can now have a row which consists of a key and a list of super
columns which by itself has keys and per key a list of columns.
Once the ColumnFamily uses SuperColumn, the column
type must be “Super”. By default the column type is “Standard” which means
common Column.
3.4.2. CLI (TODO)
To be added here!
3.5. Others?
Please refer to http://wiki.apache.org/cassandra/API
for more.
分享到:
相关推荐
Learning Apache Cassandra 2015
Learning_Apache_Cassandra .pdf
The book is aimed at intermediate developers with an understanding of core database concepts and want to become a master implementing Cassandra for their application. Table of Contents Chapter 1. ...
Learning Apache Cassandra - Second Edition by Sandeep Yarabarla English | 25 Apr. 2017 | ASIN: B01N52R0B5 | 360 Pages | AZW3 | 10.68 MB Key Features Install Cassandra and set up multi-node clusters ...
Spring Data for Apache Cassandra API。 Spring Data for Apache Cassandra 开发文档
Beginning Apache Cassandra Development introduces you to one of the most robust and best-performing NoSQL database platforms on the planet. Apache Cassandra is a document database following the JSON ...
Mastering Apache Cassand
Apache Cassandra is the most commonly used NoSQL database written in Java and is renowned in the industry as the only NoSQL solution that can accommodate the complex requirements of today’s modern ...
Cassandra的主要特点就是它不是一个数据库,而是由一堆数据库节点共同构成的一个分布式网络服务,对Cassandra 的一个写操作,会被复制到其他节点上去,对Cassandra的读操作,也会被路由到某个节点上面去读取。...
学习 cassandra 可以读一读,关于配置,部署,cassandra 的安全等知识
apache-cassandra-3.11.13 官网原版
Cassandra(apache-cassandra-3.11.11-bin.tar.gz)是一套开源分布式NoSQL数据库系统。它最初由Facebook开发,用于储存收件箱等简单格式数据,集GoogleBigTable的数据模型与Amazon Dynamo的完全分布式的架构于一身...
适用于ApacheCassandra:registered:的DataStax Node.js驱动程序一种现代,功能丰富且高度可调的Node.js客户端库,适用于Apache Cassandra和DSE,仅使用Cassandra的二进制协议和Cassandra查询语言。 用于Apache...
Apache Cassandra is the perfect choice for building fault tolerant and scalable databases. Implementing Cassandra will enable you to take advantage of its features which include replication of data ...
使用键空间、数据库表和分区键值访问数据,而无需编写 CQL 查询。 或者,在Cassandra:trade_mark:数据库上执行CQL查询,然后将查询结果导入MATLAB。
Apache Cassandra构建工具 Jenkins Job DSL脚本创建CI作业: jenkins-dsl/ Jenkins Job构建/测试运行时脚本: build-scripts/ Apache Cassandra打包实用程序: cassandra-release/ docker/ 建筑包 创建包含构建...