Return-Path: Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: (qmail 13164 invoked from network); 3 Feb 2011 12:14:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Feb 2011 12:14:26 -0000 Received: (qmail 9051 invoked by uid 500); 3 Feb 2011 12:14:24 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 8846 invoked by uid 500); 3 Feb 2011 12:14:21 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 8838 invoked by uid 99); 3 Feb 2011 12:14:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Feb 2011 12:14:20 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.161.172] (HELO mail-gx0-f172.google.com) (209.85.161.172) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Feb 2011 12:14:13 +0000 Received: by gxk27 with SMTP id 27so478470gxk.31 for ; Thu, 03 Feb 2011 04:13:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.110.2 with SMTP id t2mr15155795yhg.34.1296735232084; Thu, 03 Feb 2011 04:13:52 -0800 (PST) Received: by 10.147.41.10 with HTTP; Thu, 3 Feb 2011 04:13:52 -0800 (PST) X-Originating-IP: [88.183.33.171] In-Reply-To: References: Date: Thu, 3 Feb 2011 13:13:52 +0100 Message-ID: Subject: Re: Sorting in time order without using TimeUUID type column names From: Sylvain Lebresne To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=0023547c9a1de04be0049b5fb246 X-Virus-Checked: Checked by ClamAV on apache.org --0023547c9a1de04be0049b5fb246 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Feb 3, 2011 at 11:27 AM, Aditya Narayan wrote: > Hey all, > > I want to store some columns that are reminders to the users on my > application, in time sorted order in a row(timeline row of the user). > > Would it be recommended to store these reminder columns in the > timeline row with column names like: combination of timestamp(of time > when the reminder gets due) + UserId+ Reminders Count of that user; > Column Name= : : > > If you have one row by user (which is a good idea), why keep the UserId in the column name ? > Then what comparator could I use to sort them in order of the their > due time ? This comparator should be able to sort no. in descending > order.(I guess ascii type would do the opposite order) (Reminders need > to be sorted in the timeline in the order of their due time.) > *The* solution is write a custom comparator. Have a look at http://www.datastax.com/docs/0.7/data_model/column_families and http://www.sodeso.nl/?p=421 for instance. As a side note, the fact that the comparator sort in ascending order when you need descending order would be that much of a problem, since you can always do slice queries in reversed order. But even then, asciiType is not a very satisfying solution as you would have to be careful about the padding of your timestamp for it to work correctly. So again, custom comparator is the way to go. Basically I am trying to avoid 16 bytes long timeUUID first because > they are too long and the above defined key pattern is guaranteeing me > a unique key/Id for the reminder row always. > > > Thanks > Aditya Narayan > -- Sylvain --0023547c9a1de04be0049b5fb246 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Thu, Feb 3, 2011 at 11:27 AM, Aditya Narayan <adynnn@gmail.com> wrote:
Hey all,

I want to store some columns that are reminders to the users on my
application, in time sorted order in a row(timeline row of the user).

Would it be recommended to store these reminder columns in the
timeline row with column names like: combination of timestamp(of time
when the reminder gets due) + UserId+ Reminders Count of that user;
Column Name=3D <TimestampOfDueTimeInFuture>: <UserId> : <Rem= inderCountOfThisUser>

If you have on= e row by user (which is a good idea), why keep the UserId in
the = column name ?
=A0
Then what comparator could I use to sort them in order of the their
due time ? This comparator should be able to sort no. in descending
order.(I guess ascii type would do the opposite order) (Reminders need
to be sorted in the timeline in the order of their due time.)

*The* solution is write a custom comparator.
Have a look at http://www.datastax.com/docs/0.7/data_model/column_families<= /a>=A0
=A0
As a side note, the fact t= hat the comparator sort in ascending order when you
need descendi= ng order would be that much of a problem, since you can always
do slice queries in reversed order. But even then, asciiType is not a = very
satisfying=A0solution as you would have to be careful about = the padding of your=A0
timestamp for it to work correctly. So aga= in, custom comparator is the way
to go.

Basically I am trying to avoid 16 bytes long timeUUID first because
they are too long and the above defined key pattern is guaranteeing me
a unique key/Id for the reminder row always.


Thanks
Aditya Narayan

--
Sylvain
--0023547c9a1de04be0049b5fb246--