You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Ed Anuff <ed...@anuff.com> on 2010/04/27 17:28:38 UTC

Querying by date range when using TimeUUIDType ColumnFamily?

Assuming a ColumnFamily with a CompareWith of TimeUUIDType, is it possible
to call get_slice with an arbitrary date range?  How would valid values for
the start and finish attributes of the slice range be constructed?

Thanks
Ed

Re: Querying by date range when using TimeUUIDType ColumnFamily?

Posted by Ed Anuff <ed...@anuff.com>.
Yes, Lucas was correct about the nature of my original question.  I'm glad
to hear that Justin's solution works, it makes for a much simpler schema.

Ed

On Tue, Apr 27, 2010 at 3:06 PM, Lucas Di Pentima
<lu...@di-pentima.com.ar>wrote:

>
> El 27/04/2010, a las 18:23, Lee Parker escribió:
>
> > I have used the solution presented by Justin and it works just fine.
>  When you construct a TimeUUID with a specific timestamp and use that for
> the start or finish of the range slice, cassandra will use the timestamp
> embedded in the UUID even if that specific UUID doesn't exist in the index.
>  It is not an ideal solution because the timestamp you pass in may not have
> the same granularity as the one used to create your current indexes.  So,
> you might be using a standard unix epoch timestamp in seconds, while a true
> TimeUUID uses 100 nanosecond slices of time.
>
>
> I've tried it and am amazed of this feature, I don't know why I supposed
> that wouldn't work, thanks Lee & Justin!!! :)
>
> --
> Lucas Di Pentima - Santa Fe, Argentina
> Jabber: lucas@di-pentima.com.ar
> MSN: ldipenti75@hotmail.com
>
>
>
>
>

Re: Querying by date range when using TimeUUIDType ColumnFamily?

Posted by Lucas Di Pentima <lu...@di-pentima.com.ar>.
El 27/04/2010, a las 18:23, Lee Parker escribió:

> I have used the solution presented by Justin and it works just fine.  When you construct a TimeUUID with a specific timestamp and use that for the start or finish of the range slice, cassandra will use the timestamp embedded in the UUID even if that specific UUID doesn't exist in the index.  It is not an ideal solution because the timestamp you pass in may not have the same granularity as the one used to create your current indexes.  So, you might be using a standard unix epoch timestamp in seconds, while a true TimeUUID uses 100 nanosecond slices of time.


I've tried it and am amazed of this feature, I don't know why I supposed that wouldn't work, thanks Lee & Justin!!! :)

--
Lucas Di Pentima - Santa Fe, Argentina
Jabber: lucas@di-pentima.com.ar
MSN: ldipenti75@hotmail.com





Re: Querying by date range when using TimeUUIDType ColumnFamily?

Posted by Lee Parker <le...@socialagency.com>.
I have used the solution presented by Justin and it works just fine.  When
you construct a TimeUUID with a specific timestamp and use that for the
start or finish of the range slice, cassandra will use the timestamp
embedded in the UUID even if that specific UUID doesn't exist in the index.
 It is not an ideal solution because the timestamp you pass in may not have
the same granularity as the one used to create your current indexes.  So,
you might be using a standard unix epoch timestamp in seconds, while a true
TimeUUID uses 100 nanosecond slices of time.

Lee Parker
On Tue, Apr 27, 2010 at 3:29 PM, Lucas Di Pentima
<lu...@di-pentima.com.ar>wrote:

> I think what Ed asked is that having some CF with TimeUUIDType allowed him
> to call get_slice with *any* date range, even though those values weren't
> inserted in Cassandra.
>
> I'm just a newbie here, but I think that this is not possible, and to do
> just that you have to construct an additional index, maybe with this format:
>
> DateRange = { // CF - TimeUUIDType
> YYYYMMDD : { // Row, keyed by day, for example
> time_uuid1 => nil,
> time_uuid2 => nil,
> time_uuid3 => nil,
> ...
> }
> }
>
> ...being time_uuid[123], the actual column names inserted in the other CF.
>
> Is this correct?
>
> Regards
>
> El 27/04/2010, a las 16:50, Justin Sanders escribió:
>
> You're going to have to build TimeUUIDs based on the date range you are
> scanning.  Problem is most UUID libraries build version 1 UUIDs based on the
> current time.  I was able to get this working in Python by changing the
> library to allow me to pass in a time.  This isn't safe for creating unique
> UUIDs but works fine for doing slices.
>
> Justin
>
>
> On Tue, Apr 27, 2010 at 11:28 AM, Ed Anuff <ed...@anuff.com> wrote:
>
>> Assuming a ColumnFamily with a CompareWith of TimeUUIDType, is it possible
>> to call get_slice with an arbitrary date range?  How would valid values for
>> the start and finish attributes of the slice range be constructed?
>>
>> Thanks
>> Ed
>>
>
>
> --
> Lucas Di Pentima - Santa Fe, Argentina
> Jabber: lucas@di-pentima.com.ar
> MSN: ldipenti75@hotmail.com
>
>
>
>
>

Re: Querying by date range when using TimeUUIDType ColumnFamily?

Posted by Lucas Di Pentima <lu...@di-pentima.com.ar>.
I think what Ed asked is that having some CF with TimeUUIDType allowed him to call get_slice with *any* date range, even though those values weren't inserted in Cassandra.

I'm just a newbie here, but I think that this is not possible, and to do just that you have to construct an additional index, maybe with this format:

DateRange = { // CF - TimeUUIDType
	YYYYMMDD : { // Row, keyed by day, for example
		time_uuid1 => nil,
		time_uuid2 => nil,
		time_uuid3 => nil,
		...
	}
}

...being time_uuid[123], the actual column names inserted in the other CF.

Is this correct?

Regards

El 27/04/2010, a las 16:50, Justin Sanders escribió:

> You're going to have to build TimeUUIDs based on the date range you are scanning.  Problem is most UUID libraries build version 1 UUIDs based on the current time.  I was able to get this working in Python by changing the library to allow me to pass in a time.  This isn't safe for creating unique UUIDs but works fine for doing slices.
> 
> Justin
> 
> 
> On Tue, Apr 27, 2010 at 11:28 AM, Ed Anuff <ed...@anuff.com> wrote:
> Assuming a ColumnFamily with a CompareWith of TimeUUIDType, is it possible to call get_slice with an arbitrary date range?  How would valid values for the start and finish attributes of the slice range be constructed?
> 
> Thanks
> Ed
> 

--
Lucas Di Pentima - Santa Fe, Argentina
Jabber: lucas@di-pentima.com.ar
MSN: ldipenti75@hotmail.com





Re: Querying by date range when using TimeUUIDType ColumnFamily?

Posted by Justin Sanders <ju...@justinjas.com>.
You're going to have to build TimeUUIDs based on the date range you are
scanning.  Problem is most UUID libraries build version 1 UUIDs based on the
current time.  I was able to get this working in Python by changing the
library to allow me to pass in a time.  This isn't safe for creating unique
UUIDs but works fine for doing slices.

Justin


On Tue, Apr 27, 2010 at 11:28 AM, Ed Anuff <ed...@anuff.com> wrote:

> Assuming a ColumnFamily with a CompareWith of TimeUUIDType, is it possible
> to call get_slice with an arbitrary date range?  How would valid values for
> the start and finish attributes of the slice range be constructed?
>
> Thanks
> Ed
>