You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Praveen Baratam <pr...@gmail.com> on 2012/04/20 21:40:53 UTC

Help with Wide Rows with CounterColumns

Hello All,

I have a particular requirement where I need to update CounterColumns in a
Row by a specific UID which is the key for the CounterColumn in that row
and then query for those columns in that Row such that we get the top 5
UIDs with highest Counter Values.

create column family Counters
    with comparator = 'UTF8Type'
    and key_validation_class = 'UTF8Type'
    and default_validation_class = 'CounterColumnType';

Can it be done?

Re: Help with Wide Rows with CounterColumns

Posted by Praveen Baratam <pr...@gmail.com>.
Thank you Aaron.

On Mon, Apr 23, 2012 at 2:39 PM, aaron morton <aa...@thelastpickle.com>wrote:

> No.
>
> CounterColumnType only works with column values, which are not sorted.
> Sorting counters while they are being updated is potentially very
> expensive.
>
> You have a few options:
>
> 1) If the list of counters is short (say < 100 columns) get all the
> columns and sort client side.
> 2) Run a periodic task that gets all the columns, sorts client side,
> pivots so column name and values are swapped, and writes them back to
> another row. You can now get the top X columns.
> 3) Depending on your requirements, consider a different server such as
> Redis.
>
> Hope that helps.
>   -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 21/04/2012, at 7:40 AM, Praveen Baratam wrote:
>
> Hello All,
>
> I have a particular requirement where I need to update CounterColumns in a
> Row by a specific UID which is the key for the CounterColumn in that row
> and then query for those columns in that Row such that we get the top 5
> UIDs with highest Counter Values.
>
> create column family Counters
>     with comparator = 'UTF8Type'
>     and key_validation_class = 'UTF8Type'
>     and default_validation_class = 'CounterColumnType';
>
> Can it be done?
>
>
>
>
>
>

Re: Help with Wide Rows with CounterColumns

Posted by aaron morton <aa...@thelastpickle.com>.
No. 

CounterColumnType only works with column values, which are not sorted. Sorting counters while they are being updated is potentially very expensive. 

You have a few options:

1) If the list of counters is short (say < 100 columns) get all the columns and sort client side.
2) Run a periodic task that gets all the columns, sorts client side, pivots so column name and values are swapped, and writes them back to another row. You can now get the top X columns. 
3) Depending on your requirements, consider a different server such as Redis. 

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

On 21/04/2012, at 7:40 AM, Praveen Baratam wrote:

> Hello All,
> 
> I have a particular requirement where I need to update CounterColumns in a Row by a specific UID which is the key for the CounterColumn in that row and then query for those columns in that Row such that we get the top 5 UIDs with highest Counter Values.
> 
> create column family Counters
>     with comparator = 'UTF8Type'
>     and key_validation_class = 'UTF8Type'
>     and default_validation_class = 'CounterColumnType';  
> 
> Can it be done?
> 
> 
> 
>