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 7D4E29864 for ; Mon, 26 Mar 2012 16:08:15 +0000 (UTC) Received: (qmail 8204 invoked by uid 500); 26 Mar 2012 16:08:13 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 8170 invoked by uid 500); 26 Mar 2012 16:08:13 -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 8162 invoked by uid 99); 26 Mar 2012 16:08:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Mar 2012 16:08:13 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of samalgorai@gmail.com designates 209.85.212.172 as permitted sender) Received: from [209.85.212.172] (HELO mail-wi0-f172.google.com) (209.85.212.172) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Mar 2012 16:08:06 +0000 Received: by wibhj6 with SMTP id hj6so3433364wib.7 for ; Mon, 26 Mar 2012 09:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=u521FtYjdUYNwJN93EupbiSm0yfhP1EHqOY8yiLS0+M=; b=r5suTcTbUX5nMCDIZX3XwCkiax6/vKWfyuMbKpviEtkC1EyRgID0yaAcDuL7sgTuJk bkK516FJ1B3Bb9hq3odF7dkR8Z9NaH/TCsP8sldWC4DVCpReXY9l1SVUPqqrB7tXAGP8 RGCYxbVY9j+ZhN9Qfs5UlXLwfcVysUi6F83HvbzNX6t+XXVFZA65yLomOCA6qd6+Ljet XM201P4tQZbS/Jq5XrtqV26q2a/mfLwILniltFVESne9wyKatM3D779GXOGlUfZBZpbh eiPVEvxsYjNoMO6yJJgXRd+zmpd0QI+96Z6jyExVIZx9Opj2z1Yj2v1TIb6/YKi8Q1Q7 1ITQ== MIME-Version: 1.0 Received: by 10.180.24.66 with SMTP id s2mr19934685wif.7.1332778066019; Mon, 26 Mar 2012 09:07:46 -0700 (PDT) Received: by 10.223.103.16 with HTTP; Mon, 26 Mar 2012 09:07:45 -0700 (PDT) In-Reply-To: References: Date: Mon, 26 Mar 2012 21:37:45 +0530 Message-ID: Subject: Re: How to store a list of values? From: samal To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=f46d043be1d03086a904bc279355 --f46d043be1d03086a904bc279355 Content-Type: text/plain; charset=UTF-8 On Mon, Mar 26, 2012 at 9:20 PM, Ben McCann wrote: > Thanks for the reply Samal. > > I did not realize that you could store a column with null value. > values can be null or any value like [default@node] set hus['test']['wowq']='\{deeeee\'.de\;\}\+\^anything'; Value inserted. Elapsed time: 4 msec(s). [default@node] [default@node] [default@node] get hus['test']; => (column=wow, value={deeeee.de;}, timestamp=1332777722503000) => (column=wowq, value={deeeee'.de;}+^anything, timestamp=1332777767425000) Returned 2 results. Elapsed time: 65 msec(s). [default@node] > 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. > personally i have phased out Super Column year back, about CC didn't much dig into it but know key and column name can be composite. 'ben'+'task1'={ utf8+ascii:'' } > I'm trying to figure out if there's any way to accomplish what you've > suggested using Astyanax . > this is the simplest approach, should work with every client available since it is independent CF, here two call is required. > 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 >>>> >>>> >>> >> > --f46d043be1d03086a904bc279355 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

On Mon, Mar 26, 2012 at 9:20 PM, Ben McC= ann <ben@benmccan= n.com> wrote:
Thanks for the reply Samal.
=C2=A0
=C2=A0I did not realize th= at you could store a column with null value.
values can be null or any value like
[default@node] set hus['test']['wowq']= =3D'\{deeeee\'.de\;\}\+\^anything';
Value inserted.
Elapsed time: 4 msec(s).<= /span>
[= default@node]
[default@node]
[default@node] get hus[&#= 39;test'];
=3D> (column=3Dwow, value=3D{= deeeee.de;}, timestamp=3D1332777722503000)
=3D> (column=3Dwowq, value=3D{deeeee&= #39;.de;}+^anything, timestamp=3D1332777767425000)
Returned 2 results.
Elapsed time: 65 msec(s).
[default@node] =
=C2=A0
=C2=A0Do you know if this solution would work with composite columns? = =C2=A0It seems super columns are being phased out in favor of composites, b= ut I do not understand composites very well yet.
pe= rsonally i have phased out Super Column year back, about CC didn't much= dig into it but know key and column name can be composite.

'ben'+'task1'=3D{
=C2=A0=C2=A0 utf8+ascii:''=
}
=C2=A0
=C2=A0I'm trying to figure out if there's any way to accomplish wh= at you've suggested using Astyanax.
=C2=A0 this is the simplest approach, should work w= ith every client available since it is independent CF, here two call is req= uired.
=C2=A0
Thanks for the help,
Ben


On Mon, Mar 26, 201= 2 at 8:46 AM, samal <samalgorai@gmail.com> wrote:
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"=C2=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{
=C2=A0 'ben'=3D{
=C2=A0=C2=A0 blah :blah
=C2=A0=C2=A0 = blah :blah
=C2=A0=C2=A0 blah :blah
=C2=A0}
}

UserSkill=3D{<= br>=C2=A0 'ben'=3D{
=C2=A0=C2=A0=C2=A0 'java':= 9;'
=C2=A0=C2=A0=C2=A0 'cassandra':''
=C2=A0 .=C2=A0 .
=C2=A0 .
=C2=A0 'linux':''
=C2=A0 'skill':= 9;infinity'

=C2=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. =C2=A0In BigTable I could store a Protocol Buffer with a repeated field, but I'm not = sure how this is typically accomplished in Cassandra. =C2=A0One option woul= d be to store a serialized Thrift or protobuf, but I'd prefer not to do this as I beli= eve 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 comma= nd line. =C2=A0The other solution I thought of would be to use a super colu= mn and put a random UUID as the key for each skill:

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


Thanks,
Ben





--f46d043be1d03086a904bc279355--