Comparator comparates only the column inside a Key.
Key sorting is done by your partitionner.


Best regards,
Victor Kabdebon

2011/1/16 kh jo <jo80la...@yahoo.com>

> I am having some problems with creating column families and sorting them,
>
> I want to create a countries column family where I can get a sorted list of
> countries(by country's name)
>
> the following command fails:
>
> create column family Countries with comparator=LongType
> and column_metadata=[
>     {column_name: cid, validation_class: LongType, index_type: KEYS},
>     {column_name: cname, validation_class: UTF8Type},
>     {column_name: code, validation_class: UTF8Type, index_type: KEYS}
> ];
>
> IT SHOWS: 'id' could not be translated into a LongType.
>
>
> the following works:
>
> create column family Countries with comparator=UTF8Type
> and column_metadata=[
>     {column_name: cid, validation_class: LongType, index_type: KEYS},
>     {column_name: cname, validation_class: UTF8Type},
>     {column_name: code, validation_class: UTF8Type, index_type: KEYS}
> ];
>
>
> but when I insert some columns, they are not sorted as I want
>
> $countries = new ColumnFamily(Cassandra::con(), 'Countries');
> $countries->insert('Afghanistan', array('cid'=> '1', 'cname' =>
> 'Afghanistan', 'code' => 'AF'));
> $countries->insert('Germany', array('cid'=> '2', 'cname' => 'Germany',
> 'code' =>'DE'));
> $countries->insert('Zimbabwe', array('cid'=> '3', 'cname' => 'Zimbabwe',
> 'code' =>'ZM'));
>
> now:
> list Countries;
>
> shows:
> -------------------
> RowKey: Germany
> => (column=cid, value=2, timestamp=1295211346716047)
> => (column=cname, value=Germany, timestamp=1295211346716047)
> => (column=code, value=DE, timestamp=1295211346716047)
> -------------------
> RowKey: Zimbabwe
> => (column=cid, value=3, timestamp=1295211346713570)
> => (column=cname, value=Zimbabwe, timestamp=1295211346713570)
> => (column=code, value=ZM, timestamp=1295211346713570)
> -------------------
> RowKey: Afghanistan
> => (column=cid, value=1, timestamp=1295211346709448)
> => (column=cname, value=Afghanistan, timestamp=1295211346709448)
> => (column=code, value=AF, timestamp=1295211346709448)
>
>
> I don't see any sorting here?!
>
>

Reply via email to