2

I am creating a cassandra table(columnfamily) and want to confirm how my rows are alligned.

DROP TABLE Message;
CREATE TABLE Message ( category_id varchar , msg_id varchar , msg blob , PRIMARY KEY ( category_id, msg_id ) );

I am expecting the above table to store the 'msg' column in a wide row for identical ?category_id".

Desired table structure:

category1 -> {msgid1: msg} | {msgid2: msg} | {msgid3: msg}
category2-> {msgid1: msg} | {msgid2: msg}

Do I am doing right ? Is there any way I can see in cqlsh to conform storing order ?

Thanks.

4

1 回答 1

4

验证底层存储行是否符合预期的最简单方法是使用 CLI 进行测试。因此,如果我在 CQL 中执行以下操作:

cqlsh:test> CREATE TABLE Message (category_id varchar, msg_id varchar, msg varchar, PRIMARY KEY (category_id, msg_id));
cqlsh:test> INSERT INTO Message (category_id, msg_id, msg) VALUES ('catid1', 'msgid1', 'This is a test');
cqlsh:test> SELECT * FROM Message;

 category_id | msg_id | msg
-------------+--------+----------------
      catid1 | msgid1 | This is a test

(1 rows)

cassandra-cli...然后我按如下方式运行 CLI ( ):

[default@test] assume Message validator as ascii;
Assumption for column family 'message' added successfully.
[default@test] list Message;
Using default limit of 100
Using default cell limit of 100
-------------------
RowKey: catid1
=> (name=msgid1:, value=, timestamp=1380832937863000)
=> (name=msgid1:msg, value=This is a test, timestamp=1380832937863000)

您可以清楚地看到行看起来如所愿。您可以忽略顶部的空列,因为这是 Cassandra 内部使用的。

于 2013-10-03T20:48:12.257 回答