2011-07-26 27 views
3

我正在使用Cassandra 0.8.0。在Cassandra Cli中設置超級柱子系列

我無法弄清楚如何使用Cassandra-Cli將值添加到當前存在的SuperColumn中。例如:我已加入下列到我的密鑰空間

create column family authors 
with comparator = UTF8Type and subcomparator = UTF8Type 
and default_validation_class = UTF8Type 
and column_metadata = [{ 
    column_name: tags, validation_class: UTF8Type}, 
    {column_name: url, validation_class:UTF8Type}, 
    {column_name: title, validation_class: UTF8Type}, 
    {column_name: publisher, validation_class: UTF8Type}, 
    {column_name: email, validation_class: UTF8Type}]; 

我嘗試添加一行,這種超級柱做的: (輸入)[[email protected]] set authors[1]['1']['url'] = 'www.henry.com';

(輸出)[[email protected]] null 這是一個錯誤^

我試試這個太:

[[email protected]] set authors['henry']['url']['1'] = 'www.henry.com'; 

,並得到:

org.apache.cassandra.db.marshal.MarshalException: cannot parse 'henry' as hex bytes 

操作Cassandra-Cli中SuperColumns的正確語法是什麼?你能提供一個例子來設置/獲取值在cassandra-cli中的超級列嗎?

謝謝

回答

6

您需要

column_type = 'Super' and key_validation_class = UTF8Type 

添加到您的列族的定義。

+0

感謝您的回覆。如果Cassandra支持索引超級列中的子列,你會嗎? – Henry

0

您無法在超級列的子列上創建二級索引。因此,超級列的使用最適合於子列數量相對較少的用例。

相關問題