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 EB4E5D77C for ; Wed, 31 Oct 2012 21:02:37 +0000 (UTC) Received: (qmail 3259 invoked by uid 500); 31 Oct 2012 21:02:35 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 3238 invoked by uid 500); 31 Oct 2012 21:02:35 -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 3230 invoked by uid 99); 31 Oct 2012 21:02:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Oct 2012 21:02:35 +0000 X-ASF-Spam-Status: No, hits=2.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_REPLYTO_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [98.139.212.171] (HELO nm12.bullet.mail.bf1.yahoo.com) (98.139.212.171) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Oct 2012 21:02:25 +0000 Received: from [98.139.215.141] by nm12.bullet.mail.bf1.yahoo.com with NNFMP; 31 Oct 2012 21:02:04 -0000 Received: from [98.139.215.250] by tm12.bullet.mail.bf1.yahoo.com with NNFMP; 31 Oct 2012 21:02:04 -0000 Received: from [127.0.0.1] by omp1063.mail.bf1.yahoo.com with NNFMP; 31 Oct 2012 21:02:04 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 354090.74504.bm@omp1063.mail.bf1.yahoo.com Received: (qmail 59819 invoked by uid 60001); 31 Oct 2012 21:02:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1351717324; bh=d/z8VAlo7yye3PHhYObP/XgYfGz9gseEmre5kaQGABo=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=esgqP6DQzOq8bFxtcD5RTcZDerPHE7F3DTFtaEg0qN9xjkX1a6Sr/JGLcdb9mVXQ2sHVTPe3byLMcaovqchYG365lf6BrvTa/yHQZUXEbaHczN1/2fbzI2iLg7ItbwCE83I+yli+EC/TLg/vtB1wjKxk5jus0dOydcTgPosvyjo= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=XcAVO+De5R4VPeMi6loLQjoPBuTmYdlHnX8Ofl2SBBpkQDehyxzEjiY4E81EjXs+a7igOu4M3S3rFzENQEl55q1g6J3iqkjIsscJupb9ol2x3g7tmV6sPG7AdUE6aBiD5iNbMylnVID6BH9oSuBmuEZrSysBB/15wge7DGvKKE8=; X-YMail-OSG: Jmlmjq8VM1mBkr5whzjPljgTnScAVm2y1BxGrxSNZNKUsB5 2zZq_NZtoVvL7WDoajbxz2IWSQRnKkDGBIUKOKz.mfCE90e7CLPAmM8oFnbE nNMF02q74DtsonF6D6CEh3FuIP1vwI1994BH1pnlQ2v68MFxZuLel.OPHNC4 XBcU94oPteasTextzQrcEgTyUZTmQ0AUEi5wMcLd5sf1s4u_pZQnDiW1SvW_ OONTBuS8uVIvSvP7Gc0R6GPTjxcEyxh0PZkf7hOBQk_XUOggBy3_5r5iyEzk 1DWVlX2Qg9sSwY7xQlIm3xHLnpuDLYam4qPIfczuwTNTq0.W9IjT9fVLlCmR 73yqxFDsao.qZilDmT7UKnwxtoz4D6k4T8spXkWeKj938z_N3EDFGgsbnPNg MLKsaqMeFFugHNm2dhALuK_5FR7l8nzAfLB4PrH3ZF9YHlUOq_G_z9uBn3Zd UGvb.PFfAL75halQSwaJ.yZq4JHawg7K7rNOizGQXw41_Xo24S0MA8j4lySt K Received: from [199.21.86.226] by web160904.mail.bf1.yahoo.com via HTTP; Wed, 31 Oct 2012 14:02:04 PDT X-Rocket-MIMEInfo: 001.001,VGhhbmtzIFRyaXN0YW4gYW5kIFN5bHZhaW4sIGl0IGFsbCBtYWtlcyBzZW5zZSBub3cuwqAKCk9uZSBmb2xsb3cgdXAgcXVlc3Rpb24gcmVnYXJkaW5nIHRoZSBjb21wb3NpdGUgY29sdW1uLiBJdCBzZWVtcyB0aGF0IGZvciB0aGUgd2hlcmUgY2xhdXNlIEkgY2FuIG9ubHkgcmVzdHJpY3QgdGhlIHF1ZXJ5IG9uIHRoZSBmaXJzdCBjb21wb3NpdGUgY29sdW1uIChmcmllbmRfaWQsIGluIG15IGNhc2UpLiBJIHVuZGVyc3RhbmQgaXQncyBkZXRlcm1pbmVkIGJ5IHRoZSB1bmRlcmxpbmluZyByb3cgc3RvcmFnZSABMAEBAQE- X-Mailer: YahooMailWebService/0.8.123.460 References: <1351703649.19424.YahooMailNeo@web160902.mail.bf1.yahoo.com> Message-ID: <1351717324.55909.YahooMailNeo@web160904.mail.bf1.yahoo.com> Date: Wed, 31 Oct 2012 14:02:04 -0700 (PDT) From: Wei Zhu Reply-To: Wei Zhu Subject: Re: Create CF with composite column through CQL 3 To: "user@cassandra.apache.org" In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-517069186-406578969-1351717324=:55909" X-Virus-Checked: Checked by ClamAV on apache.org ---517069186-406578969-1351717324=:55909 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Thanks Tristan and Sylvain, it all makes sense now.=A0=0A=0AOne follow up q= uestion regarding the composite column. It seems that for the where clause = I can only restrict the query on the first composite column (friend_id, in = my case). I understand it's determined by the underlining row storage struc= ture.=A0=0AIs any plan to improve that to be able to search on the other co= mposite columns if I don't care about the performance.=0A=0Acqlsh:demo> sel= ect * from friends where source =3D 7;=0ABad Request: PRIMARY KEY part sour= ce cannot be restricted (preceding part status is either not restricted or = by a non-EQ relation)=0A=0A=0AThanks.=0A-Wei=0A=0A=0A______________________= __________=0A From: Tristan Seligmann =0ATo: user@= cassandra.apache.org; Wei Zhu =0ASent: Wednesday, Octobe= r 31, 2012 10:47 AM=0ASubject: Re: Create CF with composite column through = CQL 3=0A =0AOn Wed, Oct 31, 2012 at 7:14 PM, Wei Zhu wro= te:=0A> I try to use CQL3 to create CF with composite columns,=0A>=0A>=A0 C= REATE TABLE Friends (=0A>=A0 =A0 =A0 =A0 =A0 ...=A0 =A0 user_id bigint,=0A= >=A0 =A0 =A0 =A0 =A0 ...=A0 =A0 friend_id bigint,=0A>=A0 =A0 =A0 =A0 =A0 .= ..=A0 =A0 status int,=0A>=A0 =A0 =A0 =A0 =A0 ...=A0 =A0 source int,=0A>= =A0 =A0 =A0 =A0 =A0 ...=A0 =A0 created timestamp,=0A>=A0 =A0 =A0 =A0 =A0 .= ..=A0 =A0 lastupdated timestamp,=0A>=A0 =A0 =A0 =A0 =A0 ...=A0 =A0 PRIMAR= Y KEY (user_id, friend_id, status, source)=0A>=A0 =A0 =A0 =A0 =A0 ... );=0A= >=0A>=0A> When I check it with cli, the composite type is a bit odd, why it= 's defined=0A> as Long, Int32, Int32, UTF8, is it supposed to be Long, Long= , Int32, Int32?=0A=0AThe first component of the PRIMARY KEY (user_id) is th= e row key:=0A=0A>=A0 =A0 =A0 Key Validation Class: org.apache.cassandra.db= .marshal.LongType=0A=0AThe rest of the components (friend_id, status, sourc= e) are part of the=0Acolumn name:=0A=0A>=A0 =A0 =A0 Columns sorted by: org= .apache.cassandra.db.marshal.CompositeType(=0A> org.apache.cassandra.db.mar= shal.LongType,=0A> org.apache.cassandra.db.marshal.Int32Type,=0A> org.apach= e.cassandra.db.marshal.Int32Type,=0A=0Aand the final component of of the co= lumn name is the "CQL-level" column name:=0A=0A> org.apache.cassandra.db.ma= rshal.UTF8Type)=0A=0AIn this case, it will be "created" or "lastupdated" as= those are the=0Aonly columns not part of the PRIMARY KEY.=0A-- =0Amithrand= i, i Ainil en-Balandor, a faer Ambar ---517069186-406578969-1351717324=:55909 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks Tristan and Sylvain,= it all makes sense now. 

One follow up question reg= arding the composite column. It seems that for the where clause I can only = restrict the query on the first composite column (friend_id, in my case). I= understand it's determined by the underlining row storage structure. =
Is any plan to improve that to be able to search on the other composite= columns if I don't care about the performance.

cqlsh:demo&g= t; select * from friends where source =3D 7;
Bad Request: PRIMARY KEY pa= rt source cannot be restricted (preceding part status is either not restric= ted or by a non-EQ relation)


Thanks.
-= Wei


From= : Tristan Seligmann <mithrandi@mithrandi.net>
To: user@cassandra.apache.org; Wei= Zhu <wz1975@yahoo.com>
Se= nt: Wednesday, October 31, 2012 10:47 AM
Subject: Re: Create CF with composite column through CQL 3<= br>

=0AOn Wed, Oct 31, 2012 at 7:14 PM, Wei Zhu <wz1975@= yahoo.com> wrote:
> I try to use CQL3 to create CF with compos= ite columns,
>
>  CREATE TABLE Friends (
>  &nb= sp;       ...    user_id bigint,
>  &n= bsp;       ...    friend_id bigint,
> =         ...    status int,
>  &n= bsp;       ...    source int,
>   = ;       ...    created timestamp,
>  &= nbsp;       ...    lastupdated timestamp,
>=           ...    PRIMARY KEY (user_id, = friend_id, status, source)
>          ... );=
>
>
> When I check it with cli, the composite type is a = bit odd, why it's defined
> as Long, Int32, Int32, UTF8, is it supposed to be Long, Lo= ng, Int32, Int32?

The first component of the PRIMARY KEY (user_id) i= s the row key:

>      Key Validation Class: org.a= pache.cassandra.db.marshal.LongType

The rest of the components (frie= nd_id, status, source) are part of the
column name:

>  &n= bsp;   Columns sorted by: org.apache.cassandra.db.marshal.CompositeTy= pe(
> org.apache.cassandra.db.marshal.LongType,
> org.apache.ca= ssandra.db.marshal.Int32Type,
> org.apache.cassandra.db.marshal.Int32= Type,

and the final component of of the column name is the "CQL-leve= l" column name:

> org.apache.cassandra.db.marshal.UTF8Type)
In this case, it will be "created" or "lastupdated" as those are the
o= nly columns not part of the PRIMARY KEY.
--
mithrandi, i Ainil en-Ba= landor, a faer Ambar


---517069186-406578969-1351717324=:55909--