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/27 04:34:19 UTC

I have TimeUUID sorted keys. Can I get the range query return rows in the same order as sorted keys?

Hi,
I have the following 2 column families - one being used to store full rows
for an entity and other is an index table for having the TimeUUID sorted row
keys.

I am able to query the TimeUUID columns under the super column fine. But now
I need to go to main CF and get the data and I want the rows in the same
time order as the keys.

I am using MultiGetSliceQuery to query the main entity data for the sorted
keys, but the rows don't come back in the same order, which defeats the
purpose of storing the time sorted subcolumns. I suppose for each key, I can
fire an individual SliceQuery, but that does not look efficient to me. I do
want to fire a range query.

MainEntityCF {
         TimeUUIDKeyA: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
         TimeUUIDKeyX: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
         TimeUUIDKeyB: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
         TimeUUIDKeyY: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
}
MainEntityCF_Index {
      "SomeSuperColumn": [TimeUUIDKeyA:null, TimeUUIDKeyB:null,
TimeUUIDKeyX:null, TimeUUIDKeyY:null]
}

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

Re: I have TimeUUID sorted keys. Can I get the range query return rows in the same order as sorted keys?

Posted by Roshan Dawrani <ro...@gmail.com>.
Thanks for the references. I will have a look at them to become familiar
with them.

But for now, my rather simplistic need is fulfilled by first getting the
time-sorted keys from sub-columns and then arranging the result of a
multi_get_slice_query in the same order at the app level.

For now I don't want to get into OPP to achieve it - as I see some "be
careful" annotations with it. Nice and simple to start in Cassandra field.
:-) Thanks again for the information though.


On Mon, Dec 27, 2010 at 11:15 PM, Tyler Hobbs <ty...@riptano.com> wrote:

> Might as well link to this nice article for any discussions of OPP vs RP:
>
>
> http://ria101.wordpress.com/2010/02/22/cassandra-randompartitioner-vs-orderpreservingpartitioner/
>
> - Tyler
>
>
> On Mon, Dec 27, 2010 at 11:18 AM, Narendra Sharma <
> narendra.sharma@gmail.com> wrote:
>
>> You will need to use OPP to perform range scans. Look for Range Queries on
>> http://wiki.apache.org/cassandra/DataModel
>>
>> Look at this to understand why range queries are not supported for
>> RamdomPartitioner (https://issues.apache.org/jira/browse/CASSANDRA-1750)
>>
>> Thanks,
>> Naren
>>
>>
>> On Mon, Dec 27, 2010 at 8:35 AM, Roshan Dawrani <ro...@gmail.com>wrote:
>>
>>> I had seen RangeSlicesQuery, but I didn't notice that I could also give a
>>> key range there.
>>>
>>> How does a KeyRange work? Doesn't it need some sort from the partitioner
>>> - whether that is order preserving or not?
>>>
>>> I couldn't be sure of a query that was based on order of the rows in the
>>> column family, so I didn't explore that much.
>>>
>>>
>>>
>>> On Mon, Dec 27, 2010 at 9:55 PM, Narendra Sharma <
>>> narendra.sharma@gmail.com> wrote:
>>>
>>>> Did you look at get_range_slices? Once you get the columns from super
>>>> column, pick the first and last to form the range and fire the
>>>> get_range_slice.
>>>>
>>>> Thanks,
>>>> -Naren
>>>>
>>>>
>>>> On Mon, Dec 27, 2010 at 6:12 AM, Roshan Dawrani <
>>>> roshandawrani@gmail.com> wrote:
>>>>
>>>>> This silly question is retrieved back with apology. There couldn't be
>>>>> anything easier to handle at the application level.
>>>>>
>>>>> rgds,
>>>>> Roshan
>>>>>
>>>>>
>>>>> On Mon, Dec 27, 2010 at 9:04 AM, Roshan Dawrani <
>>>>> roshandawrani@gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>> I have the following 2 column families - one being used to store full
>>>>>> rows for an entity and other is an index table for having the TimeUUID
>>>>>> sorted row keys.
>>>>>>
>>>>>> I am able to query the TimeUUID columns under the super column fine.
>>>>>> But now I need to go to main CF and get the data and I want the rows in the
>>>>>> same time order as the keys.
>>>>>>
>>>>>> I am using MultiGetSliceQuery to query the main entity data for the
>>>>>> sorted keys, but the rows don't come back in the same order, which defeats
>>>>>> the purpose of storing the time sorted subcolumns. I suppose for each key, I
>>>>>> can fire an individual SliceQuery, but that does not look efficient to me. I
>>>>>> do want to fire a range query.
>>>>>>
>>>>>> MainEntityCF {
>>>>>>          TimeUUIDKeyA: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>>>> "Val3"]
>>>>>>          TimeUUIDKeyX: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>>>> "Val3"]
>>>>>>          TimeUUIDKeyB: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>>>> "Val3"]
>>>>>>          TimeUUIDKeyY: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>>>> "Val3"]
>>>>>> }
>>>>>> MainEntityCF_Index {
>>>>>>       "SomeSuperColumn": [TimeUUIDKeyA:null, TimeUUIDKeyB:null,
>>>>>> TimeUUIDKeyX:null, TimeUUIDKeyY:null]
>>>>>> }
>>>>>>
>>>>>> --
>>>>>> Roshan
>>>>>> Blog: http://roshandawrani.wordpress.com/
>>>>>> Twitter: @roshandawrani <http://twitter.com/roshandawrani>
>>>>>> Skype: roshandawrani
>>>>>>
>>>>>>
>>>>
>>>
>>>
>>> --
>>> Roshan
>>> Blog: http://roshandawrani.wordpress.com/
>>> Twitter: @roshandawrani <http://twitter.com/roshandawrani>
>>> Skype: roshandawrani
>>>
>>>
>>
>


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

Re: I have TimeUUID sorted keys. Can I get the range query return rows in the same order as sorted keys?

Posted by Tyler Hobbs <ty...@riptano.com>.
Might as well link to this nice article for any discussions of OPP vs RP:

http://ria101.wordpress.com/2010/02/22/cassandra-randompartitioner-vs-orderpreservingpartitioner/

- Tyler

On Mon, Dec 27, 2010 at 11:18 AM, Narendra Sharma <narendra.sharma@gmail.com
> wrote:

> You will need to use OPP to perform range scans. Look for Range Queries on
> http://wiki.apache.org/cassandra/DataModel
>
> Look at this to understand why range queries are not supported for
> RamdomPartitioner (https://issues.apache.org/jira/browse/CASSANDRA-1750)
>
> Thanks,
> Naren
>
>
> On Mon, Dec 27, 2010 at 8:35 AM, Roshan Dawrani <ro...@gmail.com>wrote:
>
>> I had seen RangeSlicesQuery, but I didn't notice that I could also give a
>> key range there.
>>
>> How does a KeyRange work? Doesn't it need some sort from the partitioner -
>> whether that is order preserving or not?
>>
>> I couldn't be sure of a query that was based on order of the rows in the
>> column family, so I didn't explore that much.
>>
>>
>>
>> On Mon, Dec 27, 2010 at 9:55 PM, Narendra Sharma <
>> narendra.sharma@gmail.com> wrote:
>>
>>> Did you look at get_range_slices? Once you get the columns from super
>>> column, pick the first and last to form the range and fire the
>>> get_range_slice.
>>>
>>> Thanks,
>>> -Naren
>>>
>>>
>>> On Mon, Dec 27, 2010 at 6:12 AM, Roshan Dawrani <roshandawrani@gmail.com
>>> > wrote:
>>>
>>>> This silly question is retrieved back with apology. There couldn't be
>>>> anything easier to handle at the application level.
>>>>
>>>> rgds,
>>>> Roshan
>>>>
>>>>
>>>> On Mon, Dec 27, 2010 at 9:04 AM, Roshan Dawrani <
>>>> roshandawrani@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>> I have the following 2 column families - one being used to store full
>>>>> rows for an entity and other is an index table for having the TimeUUID
>>>>> sorted row keys.
>>>>>
>>>>> I am able to query the TimeUUID columns under the super column fine.
>>>>> But now I need to go to main CF and get the data and I want the rows in the
>>>>> same time order as the keys.
>>>>>
>>>>> I am using MultiGetSliceQuery to query the main entity data for the
>>>>> sorted keys, but the rows don't come back in the same order, which defeats
>>>>> the purpose of storing the time sorted subcolumns. I suppose for each key, I
>>>>> can fire an individual SliceQuery, but that does not look efficient to me. I
>>>>> do want to fire a range query.
>>>>>
>>>>> MainEntityCF {
>>>>>          TimeUUIDKeyA: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>>> "Val3"]
>>>>>          TimeUUIDKeyX: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>>> "Val3"]
>>>>>          TimeUUIDKeyB: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>>> "Val3"]
>>>>>          TimeUUIDKeyY: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>>> "Val3"]
>>>>> }
>>>>> MainEntityCF_Index {
>>>>>       "SomeSuperColumn": [TimeUUIDKeyA:null, TimeUUIDKeyB:null,
>>>>> TimeUUIDKeyX:null, TimeUUIDKeyY:null]
>>>>> }
>>>>>
>>>>> --
>>>>> Roshan
>>>>> Blog: http://roshandawrani.wordpress.com/
>>>>> Twitter: @roshandawrani <http://twitter.com/roshandawrani>
>>>>> Skype: roshandawrani
>>>>>
>>>>>
>>>
>>
>>
>> --
>> Roshan
>> Blog: http://roshandawrani.wordpress.com/
>> Twitter: @roshandawrani <http://twitter.com/roshandawrani>
>> Skype: roshandawrani
>>
>>
>

Re: I have TimeUUID sorted keys. Can I get the range query return rows in the same order as sorted keys?

Posted by Narendra Sharma <na...@gmail.com>.
You will need to use OPP to perform range scans. Look for Range Queries on
http://wiki.apache.org/cassandra/DataModel

Look at this to understand why range queries are not supported for
RamdomPartitioner (https://issues.apache.org/jira/browse/CASSANDRA-1750)

Thanks,
Naren

On Mon, Dec 27, 2010 at 8:35 AM, Roshan Dawrani <ro...@gmail.com>wrote:

> I had seen RangeSlicesQuery, but I didn't notice that I could also give a
> key range there.
>
> How does a KeyRange work? Doesn't it need some sort from the partitioner -
> whether that is order preserving or not?
>
> I couldn't be sure of a query that was based on order of the rows in the
> column family, so I didn't explore that much.
>
>
>
> On Mon, Dec 27, 2010 at 9:55 PM, Narendra Sharma <
> narendra.sharma@gmail.com> wrote:
>
>> Did you look at get_range_slices? Once you get the columns from super
>> column, pick the first and last to form the range and fire the
>> get_range_slice.
>>
>> Thanks,
>> -Naren
>>
>>
>> On Mon, Dec 27, 2010 at 6:12 AM, Roshan Dawrani <ro...@gmail.com>wrote:
>>
>>> This silly question is retrieved back with apology. There couldn't be
>>> anything easier to handle at the application level.
>>>
>>> rgds,
>>> Roshan
>>>
>>>
>>> On Mon, Dec 27, 2010 at 9:04 AM, Roshan Dawrani <roshandawrani@gmail.com
>>> > wrote:
>>>
>>>> Hi,
>>>> I have the following 2 column families - one being used to store full
>>>> rows for an entity and other is an index table for having the TimeUUID
>>>> sorted row keys.
>>>>
>>>> I am able to query the TimeUUID columns under the super column fine. But
>>>> now I need to go to main CF and get the data and I want the rows in the same
>>>> time order as the keys.
>>>>
>>>> I am using MultiGetSliceQuery to query the main entity data for the
>>>> sorted keys, but the rows don't come back in the same order, which defeats
>>>> the purpose of storing the time sorted subcolumns. I suppose for each key, I
>>>> can fire an individual SliceQuery, but that does not look efficient to me. I
>>>> do want to fire a range query.
>>>>
>>>> MainEntityCF {
>>>>          TimeUUIDKeyA: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>> "Val3"]
>>>>          TimeUUIDKeyX: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>> "Val3"]
>>>>          TimeUUIDKeyB: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>> "Val3"]
>>>>          TimeUUIDKeyY: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>>> "Val3"]
>>>> }
>>>> MainEntityCF_Index {
>>>>       "SomeSuperColumn": [TimeUUIDKeyA:null, TimeUUIDKeyB:null,
>>>> TimeUUIDKeyX:null, TimeUUIDKeyY:null]
>>>> }
>>>>
>>>> --
>>>> Roshan
>>>> Blog: http://roshandawrani.wordpress.com/
>>>> Twitter: @roshandawrani <http://twitter.com/roshandawrani>
>>>> Skype: roshandawrani
>>>>
>>>>
>>
>
>
> --
> Roshan
> Blog: http://roshandawrani.wordpress.com/
> Twitter: @roshandawrani <http://twitter.com/roshandawrani>
> Skype: roshandawrani
>
>

Re: I have TimeUUID sorted keys. Can I get the range query return rows in the same order as sorted keys?

Posted by Roshan Dawrani <ro...@gmail.com>.
I had seen RangeSlicesQuery, but I didn't notice that I could also give a
key range there.

How does a KeyRange work? Doesn't it need some sort from the partitioner -
whether that is order preserving or not?

I couldn't be sure of a query that was based on order of the rows in the
column family, so I didn't explore that much.


On Mon, Dec 27, 2010 at 9:55 PM, Narendra Sharma
<na...@gmail.com>wrote:

> Did you look at get_range_slices? Once you get the columns from super
> column, pick the first and last to form the range and fire the
> get_range_slice.
>
> Thanks,
> -Naren
>
>
> On Mon, Dec 27, 2010 at 6:12 AM, Roshan Dawrani <ro...@gmail.com>wrote:
>
>> This silly question is retrieved back with apology. There couldn't be
>> anything easier to handle at the application level.
>>
>> rgds,
>> Roshan
>>
>>
>> On Mon, Dec 27, 2010 at 9:04 AM, Roshan Dawrani <ro...@gmail.com>wrote:
>>
>>> Hi,
>>> I have the following 2 column families - one being used to store full
>>> rows for an entity and other is an index table for having the TimeUUID
>>> sorted row keys.
>>>
>>> I am able to query the TimeUUID columns under the super column fine. But
>>> now I need to go to main CF and get the data and I want the rows in the same
>>> time order as the keys.
>>>
>>> I am using MultiGetSliceQuery to query the main entity data for the
>>> sorted keys, but the rows don't come back in the same order, which defeats
>>> the purpose of storing the time sorted subcolumns. I suppose for each key, I
>>> can fire an individual SliceQuery, but that does not look efficient to me. I
>>> do want to fire a range query.
>>>
>>> MainEntityCF {
>>>          TimeUUIDKeyA: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>> "Val3"]
>>>          TimeUUIDKeyX: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>> "Val3"]
>>>          TimeUUIDKeyB: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>> "Val3"]
>>>          TimeUUIDKeyY: ["Col1" : "Val1", "Col2" : "Val2", "Col3" :
>>> "Val3"]
>>> }
>>> MainEntityCF_Index {
>>>       "SomeSuperColumn": [TimeUUIDKeyA:null, TimeUUIDKeyB:null,
>>> TimeUUIDKeyX:null, TimeUUIDKeyY:null]
>>> }
>>>
>>> --
>>> Roshan
>>> Blog: http://roshandawrani.wordpress.com/
>>> Twitter: @roshandawrani <http://twitter.com/roshandawrani>
>>> Skype: roshandawrani
>>>
>>>
>


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

Re: I have TimeUUID sorted keys. Can I get the range query return rows in the same order as sorted keys?

Posted by Narendra Sharma <na...@gmail.com>.
Did you look at get_range_slices? Once you get the columns from super
column, pick the first and last to form the range and fire the
get_range_slice.

Thanks,
-Naren

On Mon, Dec 27, 2010 at 6:12 AM, Roshan Dawrani <ro...@gmail.com>wrote:

> This silly question is retrieved back with apology. There couldn't be
> anything easier to handle at the application level.
>
> rgds,
> Roshan
>
>
> On Mon, Dec 27, 2010 at 9:04 AM, Roshan Dawrani <ro...@gmail.com>wrote:
>
>> Hi,
>> I have the following 2 column families - one being used to store full rows
>> for an entity and other is an index table for having the TimeUUID sorted row
>> keys.
>>
>> I am able to query the TimeUUID columns under the super column fine. But
>> now I need to go to main CF and get the data and I want the rows in the same
>> time order as the keys.
>>
>> I am using MultiGetSliceQuery to query the main entity data for the sorted
>> keys, but the rows don't come back in the same order, which defeats the
>> purpose of storing the time sorted subcolumns. I suppose for each key, I can
>> fire an individual SliceQuery, but that does not look efficient to me. I do
>> want to fire a range query.
>>
>> MainEntityCF {
>>          TimeUUIDKeyA: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
>>          TimeUUIDKeyX: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
>>          TimeUUIDKeyB: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
>>          TimeUUIDKeyY: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
>> }
>> MainEntityCF_Index {
>>       "SomeSuperColumn": [TimeUUIDKeyA:null, TimeUUIDKeyB:null,
>> TimeUUIDKeyX:null, TimeUUIDKeyY:null]
>> }
>>
>> --
>> Roshan
>> Blog: http://roshandawrani.wordpress.com/
>> Twitter: @roshandawrani <http://twitter.com/roshandawrani>
>> Skype: roshandawrani
>>
>>

Re: I have TimeUUID sorted keys. Can I get the range query return rows in the same order as sorted keys?

Posted by Roshan Dawrani <ro...@gmail.com>.
This silly question is retrieved back with apology. There couldn't be
anything easier to handle at the application level.

rgds,
Roshan

On Mon, Dec 27, 2010 at 9:04 AM, Roshan Dawrani <ro...@gmail.com>wrote:

> Hi,
> I have the following 2 column families - one being used to store full rows
> for an entity and other is an index table for having the TimeUUID sorted row
> keys.
>
> I am able to query the TimeUUID columns under the super column fine. But
> now I need to go to main CF and get the data and I want the rows in the same
> time order as the keys.
>
> I am using MultiGetSliceQuery to query the main entity data for the sorted
> keys, but the rows don't come back in the same order, which defeats the
> purpose of storing the time sorted subcolumns. I suppose for each key, I can
> fire an individual SliceQuery, but that does not look efficient to me. I do
> want to fire a range query.
>
> MainEntityCF {
>          TimeUUIDKeyA: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
>          TimeUUIDKeyX: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
>          TimeUUIDKeyB: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
>          TimeUUIDKeyY: ["Col1" : "Val1", "Col2" : "Val2", "Col3" : "Val3"]
> }
> MainEntityCF_Index {
>       "SomeSuperColumn": [TimeUUIDKeyA:null, TimeUUIDKeyB:null,
> TimeUUIDKeyX:null, TimeUUIDKeyY:null]
> }
>
> --
> Roshan
> Blog: http://roshandawrani.wordpress.com/
> Twitter: @roshandawrani <http://twitter.com/roshandawrani>
> Skype: roshandawrani
>
>