You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Roshan Dawrani <ro...@gmail.com> on 2010/12/26 08:14:40 UTC

Retrieving TimeUUID sub-columns in reverse order

Hi,

I have a super ColumnFamily that has a few super columns, with each having a
growing list of sub-columns where column name is a TimeUUID, so the
sub-columns get stored chronologically (oldest to newest)

When I retrieve this data, can I somehow retrieve the sub-columns in reverse
order - newest first?

I am using RangeSuperSlicesQuery to query the super columns and setting a
range on it with *reverse = true*, but that only sorts the data by super
column names.

How can I tell RangeSuperSlicesQuery to get the sub-columns also in reverse
order?

Thanks.

-- 
Roshan
Blog: http://roshandawrani.wordpress.com/
Twitter: @roshandawrani <http://twitter.com/roshandawrani>
Skype: roshandawrani

Re: Retrieving TimeUUID sub-columns in reverse order

Posted by Jonathan Ellis <jb...@gmail.com>.
Better would be to just reverse client-side.

On Sun, Dec 26, 2010 at 10:35 PM, Roshan Dawrani
<ro...@gmail.com> wrote:
> Thanks, but unfortunately, I need to fetch multiple super columns - each
> super column represents a particular "state" and as entities transition from
> one state to another, they move from one super column to another.
>
> So, there is no way currently I can retrieve multiple super columns with
> their sub-cols reverse sorted? If I need it, I will need to fire a separate
> query for each "state" super column?
>
>
> On Mon, Dec 27, 2010 at 9:59 AM, Jonathan Ellis <jb...@gmail.com> wrote:
>>
>> If you are fetching multiple supercolumns, then that's what you can
>> control the order of.  If you are slicing within a single supercolumn,
>> the reverse parameter will affect the order of subcolumns.
>>
>> On Sun, Dec 26, 2010 at 6:11 AM, Roshan Dawrani <ro...@gmail.com>
>> wrote:
>> > Hi Ran,
>> > I am not doing it the YAML way. I am defining my SCF through Hector API
>> > as
>> > below
>> >
>> > ================================================================
>> > ThriftCfDef cfDef = HFactory.createColumnFamilyDefinition(ksName, "SCF")
>> > cfDef.setColumnMetadata(...)
>> > cfDef.setColumnType(ColumnType.SUPER)
>> > cfDef.setSubComparatorType(ComparatorType.TIMEUUIDTYPE)
>> > ================================================================
>> >
>> > And this is the structure of the SCF:
>> > ================================================================
>> > "key1" :
>> >           "superCol1":
>> >                     SubColName1 (TimeUUID) : null
>> >                     SubColName2 (TimeUUID) : null
>> >                     SubColName3 (TimeUUID) : null
>> >           "superCol2":
>> >                     SubColName4 (TimeUUID) : null
>> >                     SubColName5 (TimeUUID) : null
>> >                     SubColName6 (TimeUUID) : null
>> > ================================================================
>> >
>> > I now try to retrieve the data as below, but for both reverse = true |
>> > false, it's only the order of supercolumns that changes. The subcolumns
>> > always come in the same order - oldest to newest
>> >
>> > ================================================================
>> > RangeSuperSlicesQuery#setRange (null, null, reverse, Integer.MAX_VALUE)
>> > //
>> > reverse = true | false
>> > ================================================================
>> >
>> > Anything I am doing wrong here?
>> >
>> > --
>> > Roshan
>> > Blog: http://roshandawrani.wordpress.com/
>> > Twitter: @roshandawrani
>> > Skype: roshandawrani
>> >
>> > On Sun, Dec 26, 2010 at 5:31 PM, Ran Tavory <ra...@gmail.com> wrote:
>> >>
>> >> Roshan, in cassandra.yaml did you define compare_subcolumns_with  for
>> >> the
>> >> SCF?
>> >> The subcolumn names are the timeuuid, not the subcolumn values, right?
>> >>
>> >> On Sun, Dec 26, 2010 at 9:14 AM, Roshan Dawrani
>> >> <ro...@gmail.com>
>> >> wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> I have a super ColumnFamily that has a few super columns, with each
>> >>> having a growing list of sub-columns where column name is a TimeUUID,
>> >>> so the
>> >>> sub-columns get stored chronologically (oldest to newest)
>> >>>
>> >>> When I retrieve this data, can I somehow retrieve the sub-columns in
>> >>> reverse order - newest first?
>> >>>
>> >>> I am using RangeSuperSlicesQuery to query the super columns and
>> >>> setting a
>> >>> range on it with reverse = true, but that only sorts the data by super
>> >>> column names.
>> >>>
>> >>> How can I tell RangeSuperSlicesQuery to get the sub-columns also in
>> >>> reverse order?
>> >>>
>> >>> Thanks.
>> >>>
>> >>> --
>> >>> Roshan
>> >>> Blog: http://roshandawrani.wordpress.com/
>> >>> Twitter: @roshandawrani
>> >>> Skype: roshandawrani
>> >>
>> >>
>> >>
>> >> --
>> >> /Ran
>> >
>> >
>>
>>
>>
>> --
>> Jonathan Ellis
>> Project Chair, Apache Cassandra
>> co-founder of Riptano, the source for professional Cassandra support
>> http://riptano.com
>
>



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com

Re: Retrieving TimeUUID sub-columns in reverse order

Posted by Roshan Dawrani <ro...@gmail.com>.
Thanks, but unfortunately, I need to fetch multiple super columns - each
super column represents a particular "state" and as entities transition from
one state to another, they move from one super column to another.

So, there is no way currently I can retrieve multiple super columns with
their sub-cols reverse sorted? If I need it, I will need to fire a separate
query for each "state" super column?


On Mon, Dec 27, 2010 at 9:59 AM, Jonathan Ellis <jb...@gmail.com> wrote:

> If you are fetching multiple supercolumns, then that's what you can
> control the order of.  If you are slicing within a single supercolumn,
> the reverse parameter will affect the order of subcolumns.
>
> On Sun, Dec 26, 2010 at 6:11 AM, Roshan Dawrani <ro...@gmail.com>
> wrote:
> > Hi Ran,
> > I am not doing it the YAML way. I am defining my SCF through Hector API
> as
> > below
> >
> > ================================================================
> > ThriftCfDef cfDef = HFactory.createColumnFamilyDefinition(ksName, "SCF")
> > cfDef.setColumnMetadata(...)
> > cfDef.setColumnType(ColumnType.SUPER)
> > cfDef.setSubComparatorType(ComparatorType.TIMEUUIDTYPE)
> > ================================================================
> >
> > And this is the structure of the SCF:
> > ================================================================
> > "key1" :
> >           "superCol1":
> >                     SubColName1 (TimeUUID) : null
> >                     SubColName2 (TimeUUID) : null
> >                     SubColName3 (TimeUUID) : null
> >           "superCol2":
> >                     SubColName4 (TimeUUID) : null
> >                     SubColName5 (TimeUUID) : null
> >                     SubColName6 (TimeUUID) : null
> > ================================================================
> >
> > I now try to retrieve the data as below, but for both reverse = true |
> > false, it's only the order of supercolumns that changes. The subcolumns
> > always come in the same order - oldest to newest
> >
> > ================================================================
> > RangeSuperSlicesQuery#setRange (null, null, reverse, Integer.MAX_VALUE)
> //
> > reverse = true | false
> > ================================================================
> >
> > Anything I am doing wrong here?
> >
> > --
> > Roshan
> > Blog: http://roshandawrani.wordpress.com/
> > Twitter: @roshandawrani
> > Skype: roshandawrani
> >
> > On Sun, Dec 26, 2010 at 5:31 PM, Ran Tavory <ra...@gmail.com> wrote:
> >>
> >> Roshan, in cassandra.yaml did you define compare_subcolumns_with  for
> the
> >> SCF?
> >> The subcolumn names are the timeuuid, not the subcolumn values, right?
> >>
> >> On Sun, Dec 26, 2010 at 9:14 AM, Roshan Dawrani <
> roshandawrani@gmail.com>
> >> wrote:
> >>>
> >>> Hi,
> >>>
> >>> I have a super ColumnFamily that has a few super columns, with each
> >>> having a growing list of sub-columns where column name is a TimeUUID,
> so the
> >>> sub-columns get stored chronologically (oldest to newest)
> >>>
> >>> When I retrieve this data, can I somehow retrieve the sub-columns in
> >>> reverse order - newest first?
> >>>
> >>> I am using RangeSuperSlicesQuery to query the super columns and setting
> a
> >>> range on it with reverse = true, but that only sorts the data by super
> >>> column names.
> >>>
> >>> How can I tell RangeSuperSlicesQuery to get the sub-columns also in
> >>> reverse order?
> >>>
> >>> Thanks.
> >>>
> >>> --
> >>> Roshan
> >>> Blog: http://roshandawrani.wordpress.com/
> >>> Twitter: @roshandawrani
> >>> Skype: roshandawrani
> >>
> >>
> >>
> >> --
> >> /Ran
> >
> >
>
>
>
> --
> Jonathan Ellis
> Project Chair, Apache Cassandra
> co-founder of Riptano, the source for professional Cassandra support
> http://riptano.com
>

Re: Retrieving TimeUUID sub-columns in reverse order

Posted by Jonathan Ellis <jb...@gmail.com>.
If you are fetching multiple supercolumns, then that's what you can
control the order of.  If you are slicing within a single supercolumn,
the reverse parameter will affect the order of subcolumns.

On Sun, Dec 26, 2010 at 6:11 AM, Roshan Dawrani <ro...@gmail.com> wrote:
> Hi Ran,
> I am not doing it the YAML way. I am defining my SCF through Hector API as
> below
>
> ================================================================
> ThriftCfDef cfDef = HFactory.createColumnFamilyDefinition(ksName, "SCF")
> cfDef.setColumnMetadata(...)
> cfDef.setColumnType(ColumnType.SUPER)
> cfDef.setSubComparatorType(ComparatorType.TIMEUUIDTYPE)
> ================================================================
>
> And this is the structure of the SCF:
> ================================================================
> "key1" :
>           "superCol1":
>                     SubColName1 (TimeUUID) : null
>                     SubColName2 (TimeUUID) : null
>                     SubColName3 (TimeUUID) : null
>           "superCol2":
>                     SubColName4 (TimeUUID) : null
>                     SubColName5 (TimeUUID) : null
>                     SubColName6 (TimeUUID) : null
> ================================================================
>
> I now try to retrieve the data as below, but for both reverse = true |
> false, it's only the order of supercolumns that changes. The subcolumns
> always come in the same order - oldest to newest
>
> ================================================================
> RangeSuperSlicesQuery#setRange (null, null, reverse, Integer.MAX_VALUE) //
> reverse = true | false
> ================================================================
>
> Anything I am doing wrong here?
>
> --
> Roshan
> Blog: http://roshandawrani.wordpress.com/
> Twitter: @roshandawrani
> Skype: roshandawrani
>
> On Sun, Dec 26, 2010 at 5:31 PM, Ran Tavory <ra...@gmail.com> wrote:
>>
>> Roshan, in cassandra.yaml did you define compare_subcolumns_with  for the
>> SCF?
>> The subcolumn names are the timeuuid, not the subcolumn values, right?
>>
>> On Sun, Dec 26, 2010 at 9:14 AM, Roshan Dawrani <ro...@gmail.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> I have a super ColumnFamily that has a few super columns, with each
>>> having a growing list of sub-columns where column name is a TimeUUID, so the
>>> sub-columns get stored chronologically (oldest to newest)
>>>
>>> When I retrieve this data, can I somehow retrieve the sub-columns in
>>> reverse order - newest first?
>>>
>>> I am using RangeSuperSlicesQuery to query the super columns and setting a
>>> range on it with reverse = true, but that only sorts the data by super
>>> column names.
>>>
>>> How can I tell RangeSuperSlicesQuery to get the sub-columns also in
>>> reverse order?
>>>
>>> Thanks.
>>>
>>> --
>>> Roshan
>>> Blog: http://roshandawrani.wordpress.com/
>>> Twitter: @roshandawrani
>>> Skype: roshandawrani
>>
>>
>>
>> --
>> /Ran
>
>



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com

Re: Retrieving TimeUUID sub-columns in reverse order

Posted by Roshan Dawrani <ro...@gmail.com>.
Hi Ran,
I am not doing it the YAML way. I am defining my SCF through Hector API as
below

================================================================
ThriftCfDef cfDef = HFactory.createColumnFamilyDefinition(ksName, "SCF")
cfDef.setColumnMetadata(...)
cfDef.setColumnType(ColumnType.SUPER)
cfDef.setSubComparatorType(ComparatorType.TIMEUUIDTYPE)
================================================================

And this is the structure of the SCF:
================================================================
"key1" :
          "superCol1":
                    SubColName1 (TimeUUID) : null
                    SubColName2 (TimeUUID) : null
                    SubColName3 (TimeUUID) : null
          "superCol2":
                    SubColName4 (TimeUUID) : null
                    SubColName5 (TimeUUID) : null
                    SubColName6 (TimeUUID) : null
================================================================

I now try to retrieve the data as below, but for both reverse = true |
false, it's only the order of supercolumns that changes. The subcolumns
always come in the same order - oldest to newest

================================================================
RangeSuperSlicesQuery#setRange (null, null, reverse, Integer.MAX_VALUE) //
reverse = true | false
================================================================

Anything I am doing wrong here?

-- 
Roshan
Blog: http://roshandawrani.wordpress.com/
Twitter: @roshandawrani <http://twitter.com/roshandawrani>
Skype: roshandawrani

On Sun, Dec 26, 2010 at 5:31 PM, Ran Tavory <ra...@gmail.com> wrote:

> Roshan, in cassandra.yaml did you define compare_subcolumns_with  for the
> SCF?
> The subcolumn names are the timeuuid, not the subcolumn values, right?
>
>
> On Sun, Dec 26, 2010 at 9:14 AM, Roshan Dawrani <ro...@gmail.com>wrote:
>
>> Hi,
>>
>> I have a super ColumnFamily that has a few super columns, with each having
>> a growing list of sub-columns where column name is a TimeUUID, so the
>> sub-columns get stored chronologically (oldest to newest)
>>
>> When I retrieve this data, can I somehow retrieve the sub-columns in
>> reverse order - newest first?
>>
>> I am using RangeSuperSlicesQuery to query the super columns and setting a
>> range on it with *reverse = true*, but that only sorts the data by super
>> column names.
>>
>> How can I tell RangeSuperSlicesQuery to get the sub-columns also in
>> reverse order?
>>
>> Thanks.
>>
>> --
>> Roshan
>> Blog: http://roshandawrani.wordpress.com/
>> Twitter: @roshandawrani <http://twitter.com/roshandawrani>
>> Skype: roshandawrani
>>
>
>
>
> --
> /Ran
>
>

Re: Retrieving TimeUUID sub-columns in reverse order

Posted by Ran Tavory <ra...@gmail.com>.
Roshan, in cassandra.yaml did you define compare_subcolumns_with  for the
SCF?
The subcolumn names are the timeuuid, not the subcolumn values, right?

On Sun, Dec 26, 2010 at 9:14 AM, Roshan Dawrani <ro...@gmail.com>wrote:

> Hi,
>
> I have a super ColumnFamily that has a few super columns, with each having
> a growing list of sub-columns where column name is a TimeUUID, so the
> sub-columns get stored chronologically (oldest to newest)
>
> When I retrieve this data, can I somehow retrieve the sub-columns in
> reverse order - newest first?
>
> I am using RangeSuperSlicesQuery to query the super columns and setting a
> range on it with *reverse = true*, but that only sorts the data by super
> column names.
>
> How can I tell RangeSuperSlicesQuery to get the sub-columns also in reverse
> order?
>
> Thanks.
>
> --
> Roshan
> Blog: http://roshandawrani.wordpress.com/
> Twitter: @roshandawrani <http://twitter.com/roshandawrani>
> Skype: roshandawrani
>



-- 
/Ran