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 07236989A for ; Mon, 26 Mar 2012 16:08:47 +0000 (UTC) Received: (qmail 12061 invoked by uid 500); 26 Mar 2012 16:08:44 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 11995 invoked by uid 500); 26 Mar 2012 16:08:44 -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 11985 invoked by uid 99); 26 Mar 2012 16:08:44 -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 16:08:44 +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 (athena.apache.org: local policy) Received: from [209.85.220.172] (HELO mail-vx0-f172.google.com) (209.85.220.172) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Mar 2012 16:08:40 +0000 Received: by vcbfk13 with SMTP id fk13so5364145vcb.31 for ; Mon, 26 Mar 2012 09:08:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=FlT2h1xgnjqW6br+R4bpccFGe79ZFxAfQXEuy5VbuDM=; b=CE+oAXzZkPRMsUtKtsaKVkwEB6IQqTBkSfJk07Zin6dALBqanQqg/uMDRnIiM7SEPu pAbGuoyN3M0OehR2vfUvH1dtcWO71BZL9a75xYHTlTcGTAtWl4VaNer05655rdxDw0sT 280SkHQnuTsgLNu4TADFtcQ7W6waWrdeUnTu7GedXQfnj2zFNpQbpaQTyk221REMP+wy Uihu8I+o+m2CsJthy3LRW5KCxWavJ4ZsVKgHeyS8scx/N6fXGvkEjAaaRRwzNcQUMCva 0fkNzAmyVG3rs5XKXnQiisH4B2rX7nzEE5NecLF5fm/AWB0w7JxgVvAJu05Q2vCYEP0F 64XA== MIME-Version: 1.0 Received: by 10.52.29.244 with SMTP id n20mr8637360vdh.22.1332778097623; Mon, 26 Mar 2012 09:08:17 -0700 (PDT) Received: by 10.220.39.8 with HTTP; Mon, 26 Mar 2012 09:08:17 -0700 (PDT) In-Reply-To: References: Date: Mon, 26 Mar 2012 18:08:17 +0200 Message-ID: Subject: Re: How to store a list of values? From: "R. Verlangen" To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=20cf307f348c12c14804bc2795d7 X-Gm-Message-State: ALoCoQkXBsyrCKNjBSTlO135K+LVg4bg7kNY5sNS8zTrur2yAWs4KRIgUiZ0b7n8Kpy+ROc/1tDH X-Virus-Checked: Checked by ClamAV on apache.org --20cf307f348c12c14804bc2795d7 Content-Type: text/plain; charset=ISO-8859-1 In this case you only neem the columns for values. You don't need the column-values to hold multiple columns (the super-column principle). So a normal CF would work. 2012/3/26 Ben McCann > Thanks for the reply Samal. I did not realize that you could store a > column with null value. Do you know if this solution would work with > composite columns? It seems super columns are being phased out in favor of > composites, but I do not understand composites very well yet. I'm trying > to figure out if there's any way to accomplish what you've suggested using > Astyanax . > > Thanks for the help, > Ben > > > On Mon, Mar 26, 2012 at 8:46 AM, samal wrote: > >> plus it is fully compatible with CQL. >> SELECT * FROM UserSkill WHERE KEY='ben'; >> >> >> On Mon, Mar 26, 2012 at 9:13 PM, samal wrote: >> >>> I would take simple approach. create one other CF "UserSkill" with row >>> key same as profile_cf key, >>> In user_skill cf will add skill as column name and value null. Columns >>> can be added or removed. >>> >>> UserProfile={ >>> '*ben*'={ >>> blah :blah >>> blah :blah >>> blah :blah >>> } >>> } >>> >>> UserSkill={ >>> '*ben*'={ >>> 'java':'' >>> 'cassandra':'' >>> . >>> . >>> . >>> 'linux':'' >>> 'skill':'infinity' >>> >>> } >>> >>> } >>> >>> >>> On Mon, Mar 26, 2012 at 12:34 PM, Ben McCann wrote: >>> >>>> I have a profile column family and want to store a list of skills in >>>> each profile. In BigTable I could store a Protocol Bufferwith a repeated field, but I'm not sure how this is typically accomplished >>>> in Cassandra. One option would be to store a serialized Thriftor protobuf, but I'd prefer not to do this as I believe Cassandra doesn't >>>> have knowledge of these formats, and so the data in the datastore would not >>>> not human readable in CQL queries from the command line. The other >>>> solution I thought of would be to use a super column and put a random UUID >>>> as the key for each skill: >>>> >>>> skills: { >>>> '4b27c2b3ac48e8df': 'java', >>>> '84bf94ea7bc92018': 'c++', >>>> '9103b9a93ce9d18': 'cobol' >>>> } >>>> >>>> Is this a good way of handling lists in Cassandra? I imagine there's >>>> some idiom I'm not aware of. I'm using the Astyanaxclient library, which only supports composite columns instead of super >>>> columns, and so the solution I proposed above would seem quite awkward in >>>> that case. Though I'm still having some trouble understanding composite >>>> columns as they seem not to be completely documented yet. Would this >>>> solution work with composite columns? >>>> >>>> Thanks, >>>> Ben >>>> >>>> >>> >> > -- With kind regards, Robin Verlangen www.robinverlangen.nl --20cf307f348c12c14804bc2795d7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable In this case you only neem the columns for values. You don't need the c= olumn-values to hold multiple columns (the super-column principle). So a no= rmal CF would work.

2012/3/26 Ben McCann = <ben@benmccann.co= m>
Thanks for the reply Samal. =A0I did no= t realize that you could store a column with null value. =A0Do you know if = this solution would work with composite columns? =A0It seems super columns = are being phased out in favor of composites, but I do not understand compos= ites very well yet. =A0I'm trying to figure out if there's any way = to accomplish what you've suggested using Astyanax.

Thanks for the help,
Ben


On Mon, M= ar 26, 2012 at 8:46 AM, samal <samalgorai@gmail.com> wrot= e:
plus it is fully compatible with CQL.
SEL= ECT * FROM UserSkill WHERE KEY=3D'ben';


On Mon, Mar 26, 2012 at 9:13 PM, samal <= span dir=3D"ltr"><samalgorai@gmail.com> wrote:
I would take simple approach. create one oth= er CF "UserSkill"=A0 with row key same as profile_cf key,
In = user_skill cf will add skill as column name and value null. Columns can be = added or removed.

UserProfile=3D{
=A0 'ben'=3D{
=A0=A0 blah :blah
=A0=A0 blah :blah
= =A0=A0 blah :blah
=A0}
}

UserSkill=3D{
=A0 'ben&= #39;=3D{
=A0=A0=A0 'java':''
=A0=A0=A0 'cassandra= ':''
=A0 .
=A0 .
=A0 .
=A0 'linux':''
=A0 'skill':'infinit= y'

=A0}

}


On = Mon, Mar 26, 2012 at 12:34 PM, Ben McCann <ben@benmccann.com> wrote:
I have a profile column family and want to s= tore a list of skills in each profile. =A0In BigTable I could store a Protocol Buffer with a repeated field, but I'm not sur= e how this is typically accomplished in Cassandra. =A0One option would be t= o store a serialized Thrift or protobuf, but I'd prefer not to do this as I believe Ca= ssandra doesn't have knowledge of these formats, and so the data in the= datastore would not not human readable in CQL queries from the command lin= e. =A0The other solution I thought of would be to use a super column and pu= t a random UUID as the key for each skill:

skills: {
=A0 '4b27c2b3ac48e8df': 'jav= a',
=A0 '84bf94ea7bc92018': 'c++',
= =A0 '9103b9a93ce9d18': 'cobol'
}

Is this a good way of handling lists in Cassandra? =A0I imagine there&= #39;s some idiom I'm not aware of. =A0I'm using the Astyanax client= library, which only supports composite columns instead of super columns, a= nd so the solution I proposed above would seem quite awkward in that case. = =A0Though I'm still having some trouble understanding composite columns= as they seem not to be completely documented yet. =A0Would this solution w= ork with composite columns?

Thanks,
Ben







--
= With kind regards,

Robin Verlangen
www.robinverlangen.nl
--20cf307f348c12c14804bc2795d7--