You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Sonny Heer <so...@gmail.com> on 2010/04/16 01:01:25 UTC

Data model question - column names sort

Need a way to have two different types of indexes.

Key: aTextKey
ColumnName: aTextColumnName:55
Value: ""

Key: aTextKey
ColumnName: 55:aTextColumnName
Value: ""

All the valuable information is stored in the column name itself.
Above two can be in different column families...

Queries:
Given a key, page me a list of numerical values sorted on aTextColumnName
Given a key, page me a list of text values sorted on a numerical value

This approach would require left padding the numeric value for the
second index so cassandra can sort on column names correctly.

Is there any other way to accomplish this?

Re: Data model question - column names sort

Posted by Jonathan Ellis <jb...@gmail.com>.
On Thu, Apr 15, 2010 at 6:01 PM, Sonny Heer <so...@gmail.com> wrote:
> Need a way to have two different types of indexes.
>
> Key: aTextKey
> ColumnName: aTextColumnName:55
> Value: ""
>
> Key: aTextKey
> ColumnName: 55:aTextColumnName
> Value: ""
>
> All the valuable information is stored in the column name itself.
> Above two can be in different column families...
>
> Queries:
> Given a key, page me a list of numerical values sorted on aTextColumnName
> Given a key, page me a list of text values sorted on a numerical value
>
> This approach would require left padding the numeric value for the
> second index so cassandra can sort on column names correctly.

Don't do that, pack the numeric value into a fixed-length byte array
instead.  Then you don't have to do any expensive string operations in
the comparator.

-Jonathan