Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Row key in Cassandra

Before I`ve found good explanation of keys in Cassandra:

Difference between partition key, composite key and clustering key in Cassandra?.

Now I am reading about partitioner and there I can see term "row key". What is the row key? How can I list it with CQL?

like image 1000
ipeacocks Avatar asked Sep 24 '15 10:09

ipeacocks


People also ask

What is row key?

RowKey is a representation of an identifier for a specific data row that may be retrieved from a TableDataProvider . Specialized implementations might also provide extra capabilities for navigation between rows, or other value added services.

What is Cassandra partition key?

The Cassandra partition key's primary goal is to query data efficiently and evenly distribute data across a cluster. It is always the first value in the definition of the primary key. A composite partition key is used to combine more than one column value to form a single partition key.

Does Cassandra have primary key?

Primary Key: - In Cassandra there are 2 different ways to use primary Key. CREATE TABLE Cass ( id int PRIMARY KEY, name text ); Create Table Cass ( id int, name text, PRIMARY KEY(id) ); In CQL, the order in which columns are defined for the PRIMARY KEY matters.


1 Answers

The row key is just another name for the PRIMARY KEY. It is the combination of all the partition and clustering fields, and it will map to just one row of data in a table. So when you do a read or write to a particular row key, it will access just one row.

In terms of the partitioner, that only uses the partition key fields, and it generates a token hash value that determines which node in a cluster the partition will be stored on. Individual rows are stored within partitions, so if there are no clustering columns, then the partition will hold a single row and the row key would be the same as the partition key.

If you have clustering columns, then you can store multiple rows within a partition and the row key will be the partition key plus the clustering key.

like image 64
Jim Meyer Avatar answered Sep 19 '22 19:09

Jim Meyer