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 4A968916D for ; Thu, 14 Jun 2012 15:37:02 +0000 (UTC) Received: (qmail 43898 invoked by uid 500); 14 Jun 2012 15:37:00 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 43870 invoked by uid 500); 14 Jun 2012 15:36:59 -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 43862 invoked by uid 99); 14 Jun 2012 15:36:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jun 2012 15:36:59 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.214.44] (HELO mail-bk0-f44.google.com) (209.85.214.44) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jun 2012 15:36:54 +0000 Received: by bkty8 with SMTP id y8so1797461bkt.31 for ; Thu, 14 Jun 2012 08:36:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding :x-gm-message-state; bh=aQCudqv0B1qgyMNCONvl0VAYWWph5uNgTmb1mkkdRHo=; b=pKsBtyR749bp82oUH0gIsWWm7HdUytpBXSGGZmAkcLstsunrdTQrJdXuoVnQ2z6CnL wdlCQw68Z5a5tMMI0qpkNZl5JZKk8hp5AaGoft8wlCmPj/ObAzYKBZnQUySyKrWOArq9 0Zb4QFuuJY3bIggIOyiTdYlgH8DtJochnTum48Tme6XvRKVObaG7A5bpj92ctD5JrQm2 20pQj2qQI+vl0mJwHHnvW0BeQ70McFVjxTMM55jj6qshzKvS1KlY71LjPeH4pY21hAhQ 2vphl8RM+KxZyNxGaVYfJ3oFfZaXmkVkrZkx761U1YpiRSSJXIvBwbWxT0Xa8p7G47pw vW2Q== MIME-Version: 1.0 Received: by 10.205.129.8 with SMTP id hg8mr1409305bkc.25.1339688192348; Thu, 14 Jun 2012 08:36:32 -0700 (PDT) Received: by 10.205.114.13 with HTTP; Thu, 14 Jun 2012 08:36:32 -0700 (PDT) X-Originating-IP: [64.101.133.138] In-Reply-To: References: <1615137824361324314.124242oleg.dulin-gmail.com@news.gmane.org> <4FD94BD1.1060807@mebigfatguy.com> Date: Thu, 14 Jun 2012 10:36:32 -0500 Message-ID: Subject: Re: Supercolumn behavior on writes From: Greg Fausak To: user@cassandra.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQnQd6kZy/I1e/u2qHezk3GusPm4NXKLOiRsSRT5I0PflpkdPzPP/mUrJsJjxIy30lBHsCNb X-Virus-Checked: Checked by ClamAV on apache.org Derek, Thanks for that! Yes, I am aware of that technique. I am currently using something very similar on an sql database. I think one of the great benefits with Cassandra is that you can invent these on the fly. I also think there is great benefit to keep all of the columns in the same row. Anyway, I didn't mean to hijack Oleg's thread. I am interested in the original question about the serialization/deserialization on write. Does anybody know? -g On Wed, Jun 13, 2012 at 11:45 PM, Derek Williams wrote: > On Wed, Jun 13, 2012 at 9:08 PM, Greg Fausak wrote: >> >> Interesting. >> >> How do you do it? >> >> I have a version 2 CF, that works fine. >> A version 3 table won't let me invent columns that >> don't exist yet. (for composite tables). =A0What's the trick? > > > You are able to get the same behaviour as non cql by doing something like > this: > > CREATE TABLE mytable ( > =A0 id bigint, > =A0 name text, > =A0 value text, > =A0 PRIMARY KEY (id, name) > ) WITH COMPACT STORAGE; > > This table will work exactly like a standard column family with no define= d > columns. For example: > > cqlsh:testing>=A0INSERT INTO mytable (id, name, value) VALUES (1, 'firstn= ame', > 'Alice'); > cqlsh:testing>=A0INSERT INTO=A0mytable (id, name, value)=A0VALUES=A0(1, '= email', > 'alice@example.org'); > cqlsh:testing>=A0INSERT INTO=A0mytable (id, name, value)=A0VALUES=A0(2, '= firstname', > 'Bob'); > cqlsh:testing>=A0INSERT INTO=A0mytable (id, name, value)=A0VALUES=A0(2, '= webpage', > 'http://bob.example.org'); > cqlsh:testing>=A0INSERT INTO=A0mytable (id, name, value)=A0VALUES=A0(2, '= email', > 'bob@example.org'); > > cqlsh:testing>=A0SELECT name, value FROM mytable WHERE id =3D 2; > =A0name =A0 =A0 =A0| value > -----------+------------------------ > =A0 =A0 =A0email | =A0 =A0 =A0 =A0bob@example.org > =A0firstname | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Bob > =A0 =A0webpage | http://bob.example.org > > Not very exciting, but when you take a look with cassandra-cli: > > [default@testing] get mytable[2]; > =3D> (column=3Demail, value=3Dbob@example.org, timestamp=3D13396482702840= 00) > =3D> (column=3Dfirstname, value=3DBob, timestamp=3D1339648270275000) > =3D> (column=3Dwebpage, value=3Dhttp://bob.example.org, > timestamp=3D1339648270280000) > Returned 3 results. > Elapsed time: 11 msec(s). > > which is exactly what you would expect from a normal cassandra column > family. > > So the trick is to separate your static columns and your dynamic columns > into separate column families.=A0Column names and types can of course be > something different then my example, and inserts can be done within a > 'BATCH' to avoid multiple round trips. > > Also, I'm not trying to advocate this as being a better solution then jus= t > using the old thrift interface, I'm just showing an example of how to do = it. > I personally do prefer this way as it is more predictable, but of course > others will have a different opinion. > > -- > Derek Williams >