Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3B8079566 for ; Mon, 26 Mar 2012 17:14:51 +0000 (UTC) Received: (qmail 56252 invoked by uid 500); 26 Mar 2012 17:14:48 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 56220 invoked by uid 500); 26 Mar 2012 17:14:48 -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 56212 invoked by uid 99); 26 Mar 2012 17:14:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Mar 2012 17:14:48 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.113.200.5] (HELO homiemail-a55.g.dreamhost.com) (208.113.200.5) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Mar 2012 17:14:42 +0000 Received: from homiemail-a55.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a55.g.dreamhost.com (Postfix) with ESMTP id 2CB6212C0B9 for ; Mon, 26 Mar 2012 10:14:20 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=thelastpickle.com; h=from :mime-version:content-type:subject:date:in-reply-to:to :references:message-id; q=dns; s=thelastpickle.com; b=JsoCwJpyrR fRM/Vs47EllVR0Jbx53NV/X7uLfSuwbkfw4W50dJqIV8Ny0qkZzbgXd3moJtlr71 hVUPwFSxJjtyJaGsrTLLpHdhp8npoJOsBUGeNqp/f4k5FLkBixwABALW4vjUD1gx 7FFQxmsF9RWuErv2Rxde2AkRW9plN/MmE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=thelastpickle.com; h=from :mime-version:content-type:subject:date:in-reply-to:to :references:message-id; s=thelastpickle.com; bh=YU09Y7eMJMyAY2XN 8eyhxE8QY78=; b=PVYIHhxkgVtu/avVH/MucaIM1JMV8PiWQG213ju1F6udqU+f 4eHWX5o9HA6rJJRjs6Bgf39MQ+WhDiICRRDy6cQKJ8fc1jsciR4/aU3SOXee31i1 Cs/wgNpH5NROQA8I3GktezRGXstH02SCrLpk/X5jJeIQpFdJPOrlEGbeLKA= Received: from [172.16.1.3] (125-236-193-159.adsl.xtra.co.nz [125.236.193.159]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: aaron@thelastpickle.com) by homiemail-a55.g.dreamhost.com (Postfix) with ESMTPSA id 9BC7A12C09F for ; Mon, 26 Mar 2012 10:14:19 -0700 (PDT) From: aaron morton Mime-Version: 1.0 (Apple Message framework v1257) Content-Type: multipart/alternative; boundary="Apple-Mail=_A462A990-945E-490B-A06C-E55746D79999" Subject: Re: CQL Reversed and Comparator reversed=true Date: Tue, 27 Mar 2012 06:14:16 +1300 In-Reply-To: To: user@cassandra.apache.org References: Message-Id: <29028D81-3078-4C90-B227-35261DA346B6@thelastpickle.com> X-Mailer: Apple Mail (2.1257) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail=_A462A990-945E-490B-A06C-E55746D79999 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 > create column family Comments > with comparator =3D 'CompositeType(UTF8Type(reversed=3DTrue), = UTF8Type)' > and key_validation_class =3D 'UTF8Type' > and default_validation_class =3D 'UTF8Type'; Looks ok.=20 > SELECT FIRST 100 REVERSED 'z'..'0' from Comments where key =3D 'xyz'; try=20 SELECT FIRST 100 REVERSED * from Comments where key =3D 'xyz'; Cheers ----------------- Aaron Morton Freelance Developer @aaronmorton http://www.thelastpickle.com On 24/03/2012, at 9:41 AM, Praveen Baratam wrote: > Hello, >=20 > I am a bit confused about how to store and retrieve columns in = Reversed order. >=20 > Currently I store comments for every blog post in a wide row per post. >=20 > I want to store and retrieve comments for each blog post in = reversed/descending order for efficiency as we display comments in = descending order by time. Each comment gets a time based sortable id = which is stored as part of the first component of the composite type. >=20 > Below is the create statement for the column family that stores = comments for posts. >=20 > create column family Comments > with comparator =3D 'CompositeType(UTF8Type(reversed=3DTrue), = UTF8Type)' > and key_validation_class =3D 'UTF8Type' > and default_validation_class =3D 'UTF8Type'; >=20 > and the CQL I use to retrieve is as follows >=20 > SELECT FIRST 100 REVERSED 'z'..'0' from Comments where key =3D 'xyz'; >=20 > Am I doing the right thing? >=20 > Are the comments stored in descending time order in CF and with this = CQL Query am I retrieving the columns in their natural sort order with = out any additional sorting overhead? >=20 > Thank you. --Apple-Mail=_A462A990-945E-490B-A06C-E55746D79999 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=iso-8859-1
create column family = Comments
    with comparator =3D = 'CompositeType(UTF8Type(reversed=3DTrue), UTF8Type)'
  =   and key_validation_class =3D 'UTF8Type'
    = and default_validation_class =3D 'UTF8Type';
Looks = ok. 

SELECT FIRST = 100 REVERSED 'z'..'0' from Comments where key =3D = 'xyz';
try 
SELECT = FIRST 100 REVERSED * from Comments where key =3D = 'xyz';

Cheers


http://www.thelastpickle.com

On 24/03/2012, at 9:41 AM, Praveen Baratam wrote:

Hello,

I am a bit confused = about how to store and retrieve columns in Reversed = order.

Currently I store comments for every = blog post in a wide row per post.

I want to store and retrieve comments for each blog post = in reversed/descending order for efficiency as we display comments in = descending order by time. Each comment gets a time based sortable id = which is stored as part of the first component of the composite = type.

Below is the create statement for the column family = that stores comments for posts.

create column = family Comments
    with comparator =3D = 'CompositeType(UTF8Type(reversed=3DTrue), UTF8Type)'
    and key_validation_class =3D = 'UTF8Type'
    and default_validation_class =3D = 'UTF8Type';

and the CQL I use to retrieve is as = follows

SELECT FIRST 100 REVERSED 'z'..'0' from = Comments where key =3D 'xyz';

Am I doing the right = thing?

Are the comments stored in descending = time order in CF and with this CQL Query am I retrieving the columns in = their natural sort order with out any additional sorting overhead?

Thank you.

= --Apple-Mail=_A462A990-945E-490B-A06C-E55746D79999--