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 D13A8CE87 for ; Tue, 10 Jul 2012 14:35:11 +0000 (UTC) Received: (qmail 20380 invoked by uid 500); 10 Jul 2012 14:35:09 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 20219 invoked by uid 500); 10 Jul 2012 14:35:09 -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 20190 invoked by uid 99); 10 Jul 2012 14:35:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jul 2012 14:35:08 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sylvain@datastax.com designates 209.85.212.44 as permitted sender) Received: from [209.85.212.44] (HELO mail-vb0-f44.google.com) (209.85.212.44) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jul 2012 14:35:01 +0000 Received: by vbbez10 with SMTP id ez10so29195vbb.31 for ; Tue, 10 Jul 2012 07:34:40 -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=P14r8b++KvX5I0lHex/8v6AA0c/aLSgiSEaw5gI9j10=; b=RQWJhlp2ExTUeYxtY/hR0bhSsqCLMz0EkW8UZozIG8Pgz09EMAlz7XnhEfFHtzu1Rk UCaL0/KIQq8TtdHuFtVz5AiYJCg7dV4Z7oI4Xf01vJIjfMrakliWVpfrNj2aYCuiEKOO zgOz1/QY+DSkvJuNE+q6URDpZAci3gqnChU0fA33W359vFE/bdD7tLGDD1rWpkzTNUjx UB87/A4h/ARTnO5PL/sRuDZuT4X490QmAZlXCxY8HYOBQdBKnJH0KuYvVXwSEyEc34Bu L9FtniP8tBit1tPT6nWI7wub97sWVLNdmGraeq6KQ7G+EvQghTjwz3XdK7jXKVnViHnv i5DQ== MIME-Version: 1.0 Received: by 10.52.27.244 with SMTP id w20mr17803686vdg.67.1341930880443; Tue, 10 Jul 2012 07:34:40 -0700 (PDT) Received: by 10.220.101.132 with HTTP; Tue, 10 Jul 2012 07:34:40 -0700 (PDT) In-Reply-To: References: <41A0E175-CC7F-49CE-8D1C-5B6624777D19@thelastpickle.com> <68406753-8A12-4F7F-875D-1CB767F1C8CA@thelastpickle.com> <08AB4D4C-0569-4B51-A319-377D2280825C@gmail.com> Date: Tue, 10 Jul 2012 16:34:40 +0200 Message-ID: Subject: Re: Dynamic CF From: Sylvain Lebresne To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=20cf307c9bd27126d004c47aa1d6 X-Gm-Message-State: ALoCoQmdMIDFbry73j8Vxi5gPn33kBslV1RSuK3urHCkBdimNBkTRtjs4Y20efL8liCfwMZ7blDm --20cf307c9bd27126d004c47aa1d6 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Jul 10, 2012 at 4:19 PM, Carlos Carrasco < carlos.carrasco@groupalia.com> wrote: > I think he means something like having a fixed set of coiumns in the table > definition, then in the actual rows having other columns not specified in > the defintion, indepentent of the composited part of the PK. When I > reviewed CQL3 for using in Gossie[1] I realized I couldn't have this, and > that it would complicate things like migrations or optional columns. For > this reason I didn't use CQL3 and instead wrote a row unmaper that detects > the discontinuities in the composited part and uses those as the boundaries > for the individual concrete rows stored in a wide row [2]. For example: > > Given a Timeline table defined as key validation UTF8Type, column name > validation CompositeType(LongType, AsciiType), value validation BytesType: > > Timeline: { > user1: { > 1341933021000000: { > Author: "Tom", > Body: "Hey!" > }, > 1341933022000000: { > Author: "Paul", > Body: "Nice", > Lat: 40.0, > Lon: 20.0 > }, > 1341933023000000: { > Author: "Lana", > Body: "Cool" > } > }, > ... > } > > Both of the following structs are valid and will be able to be unmaped > from the wide row "user1": > > type Tweet struct { > UserID string `cf:"Timeline" key:"UserID" cols:"When"` > When int64 > Author string > Body string > } > > type GeoTweet struct { > UserID string `cf:"Timeline" key:"UserID" cols:"When"` > When int64 > Author string > Body string > Lat float32 > Lon float32 > } > That's exactly how CQL3 works. In that example, you would declare: CREATE TABLE tweet ( UserID text, When int, Author text, Body text, Lat float, Long float, PRIMARY KEY (UserId, When) ) and that would layout things *exactly* like your Timeline above, but with validation. The fact that you have to declare Lat and Long does not mean that every CQL row must have them. > much nicer behaviour for model changes and migrations. > Not sure what you mean by that since adding new columns to a CQL3 definition is basically free. -- Sylvain --20cf307c9bd27126d004c47aa1d6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Tue, Jul 10, 2012 at 4:19 PM, Carlos Carrasco <carlos.carra= sco@groupalia.com> wrote:
I think he means something like having a fixed set of coiumns in the table = definition, then in the actual rows having other columns not specified in t= he defintion, indepentent of the composited part of the PK. When I reviewed= CQL3 for using in Gossie[1] I realized I couldn't have this, and that = it would complicate things like migrations or optional columns. For this re= ason I didn't use CQL3 and instead wrote a row unmaper that detects the= discontinuities in the composited part and uses those as the boundaries fo= r the individual concrete rows stored in a wide row [2]. For example:

Given a Timeline table defined as key validation UTF8Ty= pe, column name validation CompositeType(LongType, AsciiType), value valida= tion BytesType:

Timeline: {
=A0 =A0 user= 1: {
=A0 =A0 =A0 =A0 1341933021000000: {
=A0 =A0 =A0 =A0 =A0 =A0 = Author: "Tom",
=A0 =A0 =A0 =A0 =A0 =A0 Body: "Hey!= "
=A0 =A0 =A0 =A0 },
=A0 =A0 =A0 =A0 1341933022000= 000: {
=A0 =A0 =A0 =A0 =A0 =A0 Author: "Paul",
=A0 =A0 =A0 =A0 =A0 =A0 Body: "Nice",
=A0 =A0 =A0 = =A0 =A0 =A0 Lat: 40.0,
=A0 =A0 =A0 =A0 =A0 =A0 Lon: 20.0
=A0 =A0 =A0 =A0 },
=A0 =A0 =A0 =A0 1341933023000000: {
=A0 =A0 =A0 =A0 =A0 =A0 Author: "Lana",
=A0 =A0 =A0 =A0 =A0 =A0 Body: "Cool"
=A0 =A0 =A0 =A0 }<= /div>
=A0 =A0 },
=A0 =A0 ...
}

=
Both of the following structs are valid and will be able to be unmaped= from the wide row "user1":

type Tweet struct {
=A0 =A0 UserID =A0string = `cf:"Timeline" key:"UserID" cols:"When"`
=A0 =A0 When =A0 =A0int64
=A0 =A0 Author =A0string
=A0 =A0 Body =A0 =A0string
}

type GeoTweet struct {
=A0 =A0 Us= erID =A0string `cf:"Timeline" key:"UserID" cols:"W= hen"`
=A0 =A0 When =A0 =A0int64
=A0 =A0 Author =A0= string
=A0 =A0 Body =A0 =A0string
=A0 =A0 Lat =A0 =A0 float32
= =A0 =A0 Lon =A0 =A0 float32
}

That's exactly how CQL3 works. In that example, you would decl= are:
CREATE TABLE tweet (
=A0 =A0 UserID text,
=A0 =A0 When int,
=A0 =A0 Aut= hor text,
=A0 =A0 Body text,
=A0 =A0 Lat float,
=A0 =A0 Long float,
=A0 =A0 PRIMARY KEY (UserId, When)
)
and that would layout things *exactly* like your Timeline ab= ove, but with validation.

The fact that you have to declare Lat and Long does not= mean that every CQL row must have them.
=A0
much nicer behaviour for model changes and migrations.

Not sure what you mean by that since adding new colu= mns to a CQL3 definition is basically free.

--
Sylvain
--20cf307c9bd27126d004c47aa1d6--