From user-return-23932-apmail-cassandra-user-archive=cassandra.apache.org@cassandra.apache.org Sat Feb 4 03:28:49 2012 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 8A0229C9A for ; Sat, 4 Feb 2012 03:28:49 +0000 (UTC) Received: (qmail 16111 invoked by uid 500); 4 Feb 2012 03:28:47 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 15422 invoked by uid 500); 4 Feb 2012 03:28:32 -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 15414 invoked by uid 99); 4 Feb 2012 03:28:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Feb 2012 03:28:30 +0000 X-ASF-Spam-Status: No, hits=2.9 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL,T_FILL_THIS_FORM_SHORT X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.86.89.70] (HELO elasmtp-banded.atl.sa.earthlink.net) (209.86.89.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Feb 2012 03:28:21 +0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=mindspring.com; b=USbWO8nfHuiOHodXiFKM9HheDYhBwywSTkjGZAreQ6m/HzbhK2q0STPZ2ziiUcnq; h=Received:From:Mime-Version:Content-Type:Subject:Date:In-Reply-To:To:References:Message-Id:X-Mailer:X-ELNK-Trace:X-Originating-IP; Received: from [208.124.48.188] (helo=[192.168.1.5]) by elasmtp-banded.atl.sa.earthlink.net with esmtpa (Exim 4.67) (envelope-from ) id 1RtWIB-0001gX-MC for user@cassandra.apache.org; Fri, 03 Feb 2012 22:28:00 -0500 From: Chris Gerken Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: multipart/alternative; boundary=Apple-Mail-16--20955517 Subject: Re: yet a couple more questions on composite columns Date: Fri, 3 Feb 2012 21:27:58 -0600 In-Reply-To: To: user@cassandra.apache.org References: Message-Id: <6BC865B0-908C-4689-9D1F-82979DC55C61@mindspring.com> X-Mailer: Apple Mail (2.1084) X-ELNK-Trace: 89ce5298aa6460db6a4d017a94a0a954416dc04816f3191c9df4f4ce1d59cfc5210ee0b77afe5c81015960c588b74cfb350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 208.124.48.188 --Apple-Mail-16--20955517 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii >=20 >=20 > On 4 February 2012 06:21, Yiming Sun wrote: > I cannot have one composite column name with 3 components while = another with 4 components? > Just put 4 components and left last empty (if it is same type)?! >=20 > Another question I have is how flexible composite columns actually = are. If my data model has a CF containing US zip codes with the = following composite columns: >=20 > {OH:Spring Field} : 45503 > {OH:Columbus} : 43085 > {FL:Spring Field} : 32401 > {FL:Key West} : 33040 >=20 > I know I can ask cassandra to "give me the zip codes of all cities in = OH". But can I ask it to "give me the zip codes of all cities named = Spring Field" using this model? Thanks. > No. You set first composite component at first. I'd use a dynamic CF: row key =3D state abbreviation=20 column name =3D city name column value =3D zip code (or a complex object, one of whose properties = is zip code) you can iterate over the columns in a single row to get a state's city = names and their zip code and you can do a get_range_slices on all keys = for the columns starting and ending on the city name to find out the zip = codes for a cities with the given name. I think - Chris= --Apple-Mail-16--20955517 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii



On 4 February 2012 06:21, Yiming Sun <yiming.sun@gmail.com> wrote:
I cannot have one composite column name with 3 components while another with 4 components?
 Just put 4 components and left last empty (if it is same type)?!

Another question I have is how flexible composite columns actually are.  If my data model has a CF containing US zip codes with the following composite columns:

{OH:Spring Field} : 45503
{OH:Columbus} : 43085
{FL:Spring Field} : 32401
{FL:Key West}  : 33040

I know I can ask cassandra to "give me the zip codes of all cities in OH".  But can I ask it to "give me the zip codes of all cities named Spring Field" using this model?  Thanks.
No. You set first composite component at first.

I'd use a dynamic CF:
row key = state abbreviation 
column name = city name
column value = zip code (or a complex object, one of whose properties is zip code)

you can iterate over the columns in a single row to get a state's city names and their zip code and you can do a get_range_slices on all keys for the columns starting and ending on the city name to find out the zip codes for a cities with the given name.

I think

- Chris
--Apple-Mail-16--20955517--