incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aaron morton <aa...@thelastpickle.com>
Subject Re: Composite as row key
Date Mon, 18 Jun 2012 01:03:40 GMT
> Row key is a combo of 2 uuid, the first it's the user's uuid, if i want a select of all
the watchdog entrys of a user.........how can i do? is it possible? I justk know user uuid,
the other part of key is unknow uuid.
No. 
You would be doing a range scan (from key foo to key blah) and would run into this http://wiki.apache.org/cassandra/FAQ#range_rp

An alternative is to push the watchdog ID down into the column names thusly…

CREATE COLUMN FAMILY UserWatchdogs
    WITH key_validation_class = 'LexicalUUIDType'
    AND comparator ='CompositeType(LexicalUUIDType, UTF8Type)'
;

But that means you cannot create the secondary index because you wont know the name of the
columns before hand. 

wrt to the searching do you want to the search be global for all Watchdog entries or scoped
to a user ?

You can make a custom secondary index such as 

CREATE COLUMN FAMILY UserWatchdogIndex
    WITH key_validation_class = ''CompositeType(LexicalUUIDType, UTF8Type)' 	<- (user_id,
column_name)  
    AND comparator ='CompositeType(UTF8Type, LexicalUUIDType)' <- (column_value, watchdog
id)
;


> If i do with a supercolumn i can use secondary indexes, if key is composite there is
no way for select all data related to a user...............

Secondary indexes are not support on Super Columns. 

Hope that helps. 


-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 14/06/2012, at 10:28 PM, Juan Ezquerro wrote:

> I have a columnfamily like:
> 
> CREATE COLUMN FAMILY Watchdog
>     WITH key_validation_class = 'CompositeType(LexicalUUIDType,LexicalUUIDType)'
>     AND comparator = UTF8Type
>     AND column_metadata = [
>         {column_name: error_code, validation_class: UTF8Type, index_type: KEYS}
>         {column_name: line, validation_class: IntegerType}
>         {column_name: file_path, validation_class: UTF8Type}
>         {column_name: function, validation_class: UTF8Type}
>         {column_name: content, validation_class: UTF8Type}
>         {column_name: additional_data, validation_class: UTF8Type}
>         {column_name: date_created, validation_class: DateType, index_type: KEYS}
>         {column_name: priority, validation_class: IntegerType, index_type: KEYS}
>     ];
> 
> Row key is a combo of 2 uuid, the first it's the user's uuid, if i want a select of all
the watchdog entrys of a user.........how can i do? is it possible? I justk know user uuid,
the other part of key is unknow uuid.
> 
> The idea is simple, i have a user and i want all the records on watchdog, and i want
secondary index to do search.........very simple with mysql but here i can't find the way.
> 
> If i do with a supercolumn i can use secondary indexes, if key is composite there is
no way for select all data related to a user...............
> 
> The ugly way:
> 
> CREATE COLUMN FAMILY Watchdog
>     WITH key_validation_class = LexicalUUIDType
>     AND comparator = UTF8Type
>     AND column_metadata = [
>       {column_name: user_uuid, validation_class: LexicalUUIDType, index_type: KEYS}
>         {column_name: error_code, validation_class: UTF8Type, index_type: KEYS}
>         {column_name: line, validation_class: IntegerType}
>         {column_name: file_path, validation_class: UTF8Type}
>         {column_name: function, validation_class: UTF8Type}
>         {column_name: content, validation_class: UTF8Type}
>         {column_name: additional_data, validation_class: UTF8Type}
>         {column_name: date_created, validation_class: DateType, index_type: KEYS}
>         {column_name: priority, validation_class: IntegerType, index_type: KEYS}
>     ];
> 
> But i think that is not a nice solution because y always need to search in all rows of
very big tables to take all user's data...............
> 
> Please.... can help?
> 
> Thanks.
> 
> -- 
> Juan Ezquerro LLanes <Sofistic Team>
> 
> Telf: 618349107/964051479
> 


Mime
View raw message