You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Juan Manuel García del Moral <ju...@taringa.net> on 2010/03/22 21:08:55 UTC

get ordered by value

Hello

I have this:

get SocialAds.Anonimos['3539792'];
=> (super_column=Tag,
     (column=1036, value=5, timestamp=1001181414)
     (column=116, value=2, timestamp=1001181414)
     (column=121988, value=2, timestamp=1001181413)
     (column=13838, value=3, timestamp=1001181416)
     (column=14105, value=2, timestamp=1001181413)
     (column=169095, value=2, timestamp=1001181414)
     (column=30253, value=2, timestamp=1001181413)
     (column=350737, value=1, timestamp=1001181341)
     (column=350738, value=1, timestamp=1001181341))

I would need to get the column with the highest value for that CF, this is
something I have to do in the get() or in the data schema?

my schema is:

<Keyspace Name="SocialAds">

<ColumnFamily ColumnType="Super"
                    CompareWith="UTF8Type"
                    CompareSubcolumnsWith="UTF8Type"
                    Name="Anonimos"
                    RowsCached="1000"
                    KeysCached="50%"
                    Comment="A column family with supercolumns, whose column
and subcolumn names are UTF8 strings"/>

<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
      <ReplicationFactor>1</ReplicationFactor>

<EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
</Keyspace>


Any ideas?

Thanks in advance

Juan

Re: get ordered by value

Posted by Jonathan Ellis <jb...@gmail.com>.
natural order is for column names, not values

2010/3/22 Juan Manuel García del Moral <ju...@taringa.net>:
> I understand, but there isn't a way to define a data schema, and get it
> sorted in the insertion,so then the natural order would match what I need to
> query?
>
>
>
> 2010/3/22 Jonathan Ellis <jb...@gmail.com>
>>
>> You have to fetch the columns and sort client-side, for now.
>>
>> 2010/3/22 Juan Manuel García del Moral <ju...@taringa.net>:
>> > Hello
>> >
>> > I have this:
>> >
>> > get SocialAds.Anonimos['3539792'];
>> > => (super_column=Tag,
>> >      (column=1036, value=5, timestamp=1001181414)
>> >      (column=116, value=2, timestamp=1001181414)
>> >      (column=121988, value=2, timestamp=1001181413)
>> >      (column=13838, value=3, timestamp=1001181416)
>> >      (column=14105, value=2, timestamp=1001181413)
>> >      (column=169095, value=2, timestamp=1001181414)
>> >      (column=30253, value=2, timestamp=1001181413)
>> >      (column=350737, value=1, timestamp=1001181341)
>> >      (column=350738, value=1, timestamp=1001181341))
>> >
>> > I would need to get the column with the highest value for that CF, this
>> > is
>> > something I have to do in the get() or in the data schema?
>> >
>> > my schema is:
>> >
>> > <Keyspace Name="SocialAds">
>> >
>> > <ColumnFamily ColumnType="Super"
>> >                     CompareWith="UTF8Type"
>> >                     CompareSubcolumnsWith="UTF8Type"
>> >                     Name="Anonimos"
>> >                     RowsCached="1000"
>> >                     KeysCached="50%"
>> >                     Comment="A column family with supercolumns, whose
>> > column
>> > and subcolumn names are UTF8 strings"/>
>> >
>> >
>> > <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
>> >       <ReplicationFactor>1</ReplicationFactor>
>> >
>> >
>> > <EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
>> > </Keyspace>
>> >
>> >
>> > Any ideas?
>> >
>> > Thanks in advance
>> >
>> > Juan
>> >
>> >
>
>

Re: get ordered by value

Posted by Juan Manuel García del Moral <ju...@taringa.net>.
I understand, but there isn't a way to define a data schema, and get it
sorted in the insertion,so then the natural order would match what I need to
query?



2010/3/22 Jonathan Ellis <jb...@gmail.com>

> You have to fetch the columns and sort client-side, for now.
>
> 2010/3/22 Juan Manuel García del Moral <ju...@taringa.net>:
> > Hello
> >
> > I have this:
> >
> > get SocialAds.Anonimos['3539792'];
> > => (super_column=Tag,
> >      (column=1036, value=5, timestamp=1001181414)
> >      (column=116, value=2, timestamp=1001181414)
> >      (column=121988, value=2, timestamp=1001181413)
> >      (column=13838, value=3, timestamp=1001181416)
> >      (column=14105, value=2, timestamp=1001181413)
> >      (column=169095, value=2, timestamp=1001181414)
> >      (column=30253, value=2, timestamp=1001181413)
> >      (column=350737, value=1, timestamp=1001181341)
> >      (column=350738, value=1, timestamp=1001181341))
> >
> > I would need to get the column with the highest value for that CF, this
> is
> > something I have to do in the get() or in the data schema?
> >
> > my schema is:
> >
> > <Keyspace Name="SocialAds">
> >
> > <ColumnFamily ColumnType="Super"
> >                     CompareWith="UTF8Type"
> >                     CompareSubcolumnsWith="UTF8Type"
> >                     Name="Anonimos"
> >                     RowsCached="1000"
> >                     KeysCached="50%"
> >                     Comment="A column family with supercolumns, whose
> column
> > and subcolumn names are UTF8 strings"/>
> >
> >
> <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
> >       <ReplicationFactor>1</ReplicationFactor>
> >
> >
> <EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
> > </Keyspace>
> >
> >
> > Any ideas?
> >
> > Thanks in advance
> >
> > Juan
> >
> >
>

Re: get ordered by value

Posted by Jonathan Ellis <jb...@gmail.com>.
You have to fetch the columns and sort client-side, for now.

2010/3/22 Juan Manuel García del Moral <ju...@taringa.net>:
> Hello
>
> I have this:
>
> get SocialAds.Anonimos['3539792'];
> => (super_column=Tag,
>      (column=1036, value=5, timestamp=1001181414)
>      (column=116, value=2, timestamp=1001181414)
>      (column=121988, value=2, timestamp=1001181413)
>      (column=13838, value=3, timestamp=1001181416)
>      (column=14105, value=2, timestamp=1001181413)
>      (column=169095, value=2, timestamp=1001181414)
>      (column=30253, value=2, timestamp=1001181413)
>      (column=350737, value=1, timestamp=1001181341)
>      (column=350738, value=1, timestamp=1001181341))
>
> I would need to get the column with the highest value for that CF, this is
> something I have to do in the get() or in the data schema?
>
> my schema is:
>
> <Keyspace Name="SocialAds">
>
> <ColumnFamily ColumnType="Super"
>                     CompareWith="UTF8Type"
>                     CompareSubcolumnsWith="UTF8Type"
>                     Name="Anonimos"
>                     RowsCached="1000"
>                     KeysCached="50%"
>                     Comment="A column family with supercolumns, whose column
> and subcolumn names are UTF8 strings"/>
>
> <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
>       <ReplicationFactor>1</ReplicationFactor>
>
> <EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
> </Keyspace>
>
>
> Any ideas?
>
> Thanks in advance
>
> Juan
>
>

Re: get ordered by value

Posted by Peter Chang <pe...@gmail.com>.
Perhaps an inverted index would work.

supercolumn=5 subcolumn=1036
supercolumn=3 subcolumn=13838

I only used a super column family so that you could have multiple subcolumns
for the same supercolumn.

Peter

2010/3/22 Juan Manuel García del Moral <ju...@taringa.net>

> Hello
>
> I have this:
>
> get SocialAds.Anonimos['3539792'];
> => (super_column=Tag,
>      (column=1036, value=5, timestamp=1001181414)
>      (column=116, value=2, timestamp=1001181414)
>      (column=121988, value=2, timestamp=1001181413)
>      (column=13838, value=3, timestamp=1001181416)
>      (column=14105, value=2, timestamp=1001181413)
>      (column=169095, value=2, timestamp=1001181414)
>      (column=30253, value=2, timestamp=1001181413)
>      (column=350737, value=1, timestamp=1001181341)
>      (column=350738, value=1, timestamp=1001181341))
>
> I would need to get the column with the highest value for that CF, this is
> something I have to do in the get() or in the data schema?
>
> my schema is:
>
> <Keyspace Name="SocialAds">
>
> <ColumnFamily ColumnType="Super"
>                     CompareWith="UTF8Type"
>                     CompareSubcolumnsWith="UTF8Type"
>                     Name="Anonimos"
>                     RowsCached="1000"
>                     KeysCached="50%"
>                     Comment="A column family with supercolumns, whose
> column and subcolumn names are UTF8 strings"/>
>
>
> <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
>       <ReplicationFactor>1</ReplicationFactor>
>
> <EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
> </Keyspace>
>
>
> Any ideas?
>
> Thanks in advance
>
> Juan
>
>