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 B960C1096D for ; Mon, 2 Sep 2013 19:13:36 +0000 (UTC) Received: (qmail 28064 invoked by uid 500); 2 Sep 2013 19:13:34 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 27982 invoked by uid 500); 2 Sep 2013 19:13:34 -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 27974 invoked by uid 99); 2 Sep 2013 19:13:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Sep 2013 19:13:33 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of muhammed.dawood@gmail.com designates 209.85.128.171 as permitted sender) Received: from [209.85.128.171] (HELO mail-ve0-f171.google.com) (209.85.128.171) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Sep 2013 19:13:29 +0000 Received: by mail-ve0-f171.google.com with SMTP id pa12so3380198veb.16 for ; Mon, 02 Sep 2013 12:13:08 -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=URyFw9oevzvHle2dg5S1AE9XJmhUuuKJ4F3UKukYXfo=; b=bR88B4nQhfeLaOQC7ayT6po60F/4a66d8M/j1B8zh1gv/hh5WxfF2yjrXWb5gsjRvN Erk0OdjLD6QyoPJcJGxQPqVxp9rWoyw/cmSTigxQvH9oTDkFuFYnQoki5Mv7+bYqEsW7 meN3hJwRSNxhKlpphtvkiefEu62FgUyzczrwxpks1ISyctFk9Zq7IbLZAYFRdacx+2Fj IjqHU8QPJkmhCKhdW2S0O7YrQwRfHT7ZJG9zzzUUxQyh9S2Vqb56yJNJi2I71GRlEZ89 w53y4NEG23v3Ko/0knmIvamb4TxMtznxDqSp8lPdbKGXYR+vjn5AOAzRwuF2qW4VrMqp Kapg== MIME-Version: 1.0 X-Received: by 10.58.196.132 with SMTP id im4mr170665vec.28.1378149188429; Mon, 02 Sep 2013 12:13:08 -0700 (PDT) Received: by 10.52.180.67 with HTTP; Mon, 2 Sep 2013 12:13:08 -0700 (PDT) In-Reply-To: <8A136D81-BC95-4605-B0C6-C48659876598@nordsc.com> References: <8A136D81-BC95-4605-B0C6-C48659876598@nordsc.com> Date: Tue, 3 Sep 2013 00:43:08 +0530 Message-ID: Subject: Re: Versioning in cassandra From: dawood abdullah To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=047d7b6d8cc8d2f05304e56b5c48 X-Virus-Checked: Checked by ClamAV on apache.org --047d7b6d8cc8d2f05304e56b5c48 Content-Type: text/plain; charset=ISO-8859-1 In my case version can be timestamp as well. What do you suggest version number to be, do you see any problems if I keep version as counter / timestamp ? On Tue, Sep 3, 2013 at 12:22 AM, Jan Algermissen wrote: > > On 02.09.2013, at 20:44, dawood abdullah > wrote: > > > Requirement is like I have a column family say File > > > > create table file(id text primary key, fname text, version int, mimetype > text, content text); > > > > Say, I have few records inserted, when I modify an existing record > (content is modified) a new version needs to be created. As I need to have > provision to revert to back any old version whenever required. > > > > So, can version be a timestamp? Or does it need to be an integer? > > In the former case, make use of C*'s ordering like so: > > CREATE TABLE file ( > file_id text, > version timestamp, > fname text, > .... > PRIMARY KEY (file_id,version) > ) WITH CLUSTERING ORDER BY (version DESC); > > Get the latest file version with > > select * from file where file_id = 'xxx' limit 1; > > If it has to be an integer, use counter columns. > > Jan > > > > Regards, > > Dawood > > > > > > On Mon, Sep 2, 2013 at 10:47 PM, Jan Algermissen < > jan.algermissen@nordsc.com> wrote: > > Hi Dawood, > > > > On 02.09.2013, at 16:36, dawood abdullah > wrote: > > > > > Hi > > > I have a requirement of versioning to be done in Cassandra. > > > > > > Following is my column family definition > > > > > > create table file_details(id text primary key, fname text, version > int, mimetype text); > > > > > > I have a secondary index created on fname column. > > > > > > Whenever I do an insert for the same 'fname', the version should be > incremented. And when I retrieve a row with fname it should return me the > latest version row. > > > > > > Is there a better way to do in Cassandra? Please suggest what approach > needs to be taken. > > > > Can you explain more about your use case? > > > > If the version need not be a small number, but could be a timestamp, you > could make use of C*'s ordering feature , have the database set the new > version as a timestamp and retrieve the latest one with a simple LIMIT 1 > query. (I'll explain more when this is an option for you). > > > > Jan > > > > P.S. Me being a REST/HTTP head, an alarm rings when I see 'version' next > to 'mimetype' :-) What exactly are you versioning here? Maybe we can even > change the situation from a functional POV? > > > > > > > > > > Regards, > > > > > > Dawood > > > > > > > > > > > > > > > > > > --047d7b6d8cc8d2f05304e56b5c48 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
In my case version can be timestamp as well. What do you s= uggest version number to be, do you see any problems if I keep version as c= ounter / timestamp ?


On Tue, Sep 3, 2013 at 12:22 AM, Jan Algermissen <jan.algermissen= @nordsc.com> wrote:

On 02.09.2013, at 20:44, dawood abdullah <muhammed.dawood@gmail.com> wrote:

> Requirement is like I have a column family say File
>
> create table file(id text primary key, fname text, version int, mimety= pe text, content text);
>
> Say, I have few records inserted, when I modify an existing record (co= ntent is modified) a new version needs to be created. As I need to have pro= vision to revert to back any old version whenever required.
>

So, can version be a timestamp? Or does it need to be an integer?

In the former case, make use of C*'s ordering like so:

CREATE TABLE file (
=A0 =A0file_id text,
=A0 =A0version timestamp,
=A0 =A0fname text,
=A0 =A0....
=A0 =A0PRIMARY KEY (file_id,version)
) WITH CLUSTERING ORDER BY (version DESC);

Get the latest file version with

select * from file where file_id =3D 'xxx' limit 1;

If it has to be an integer, use counter columns.

Jan


> Regards,
> Dawood
>
>
> On Mon, Sep 2, 2013 at 10:47 PM, Jan Algermissen <jan.algermissen@nordsc.com> wrote:
> Hi Dawood,
>
> On 02.09.2013, at 16:36, dawood abdullah <muhammed.dawood@gmail.com> wrote:
>
> > Hi
> > I have a requirement of versioning to be done in Cassandra.
> >
> > Following is my column family definition
> >
> > create table file_details(id text primary key, fname text, versio= n int, mimetype text);
> >
> > I have a secondary index created on fname column.
> >
> > Whenever I do an insert for the same 'fname', the version= should be incremented. And when I retrieve a row with fname it should retu= rn me the latest version row.
> >
> > Is there a better way to do in Cassandra? Please suggest what app= roach needs to be taken.
>
> Can you explain more about your use case?
>
> If the version need not be a small number, but could be a timestamp, y= ou could make use of C*'s ordering feature , have the database set the = new version as a timestamp and retrieve the latest one with a simple LIMIT = 1 query. (I'll explain more when this is an option for you).
>
> Jan
>
> P.S. Me being a REST/HTTP head, an alarm rings when I see 'version= ' next to 'mimetype' :-) What exactly are you versioning here? = Maybe we can even change the situation from a functional POV?
>
>
> >
> > Regards,
> >
> > Dawood
> >
> >
> >
> >
>
>


--047d7b6d8cc8d2f05304e56b5c48--