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 50D4B11BB9 for ; Fri, 18 Jul 2014 01:40:31 +0000 (UTC) Received: (qmail 70153 invoked by uid 500); 18 Jul 2014 01:40:28 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 70117 invoked by uid 500); 18 Jul 2014 01:40:28 -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 70107 invoked by uid 99); 18 Jul 2014 01:40:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2014 01:40:28 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of clohfink@blackbirdit.com designates 209.85.213.182 as permitted sender) Received: from [209.85.213.182] (HELO mail-ig0-f182.google.com) (209.85.213.182) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2014 01:40:23 +0000 Received: by mail-ig0-f182.google.com with SMTP id c1so76787igq.3 for ; Thu, 17 Jul 2014 18:39:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:content-transfer-encoding:message-id:references:to; bh=cnQ3FGCBxBe2Z8Jf8A9VoH9InaxlFBe6CYy6GaKxGkI=; b=gRW+3UWdEYVoUv+/BgGucso8jFXT9vmrgwInpViE3EugbUDPR2MYTM2r8PMvuIhDMI 8DhfOSOiffamO5XjYSex5kXOKnHg+XHDdC/TT3mrmAQoHhHB99lBBCcX4PxuK9w4P6gp +VZKD8B/9clEKhpe//0/UZy+PAvhvz/VZA9sxOCMwc1OSFhMdqtaFz1QmrVISH8JfmX9 LhvanzgFpXUY47KtlOihx20gKohwd/13XHbJ7QAYttQYU9nHw7KlECCE7G2WbsMV3t7G KQVw/L972URHcYSlqZ323xJi8dzc/woUHnGMKV9MxqukfP0rT96Bj/JVeWbyOq+wVEV9 IOzg== X-Gm-Message-State: ALoCoQmklgxh9fnfM+FCnzFptUCqaOfB1F6AXXei++StjXAZtM55rnlHDHu+NCcV+wpd4hzkTXFw X-Received: by 10.50.117.2 with SMTP id ka2mr3112305igb.33.1405647598398; Thu, 17 Jul 2014 18:39:58 -0700 (PDT) Received: from [10.10.10.111] (97-86-246-164.dhcp.roch.mn.charter.com. [97.86.246.164]) by mx.google.com with ESMTPSA id bd5sm741264igb.16.2014.07.17.18.39.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 17 Jul 2014 18:39:57 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: How to maintain the N-most-recent versions of a value? From: Chris Lohfink In-Reply-To: Date: Thu, 17 Jul 2014 20:39:56 -0500 Content-Transfer-Encoding: quoted-printable Message-Id: <4A9E0F83-4335-43F6-9E30-6FA36C98A375@blackbirdit.com> References: To: user@cassandra.apache.org X-Mailer: Apple Mail (2.1874) X-Virus-Checked: Checked by ClamAV on apache.org I would say that would work, but since already familiar with storage = model from hbase and trying to emulate it may want to look into thrift = interfaces. They little more similar to hbase interface (not as = friendly to use and you cant use the very useful new client libraries = from datastax) and accesses storage more directly, which is similar to = hbases. You have your column family foo, then just use a composite = column to store family, qualifier, and version in column name with value = of column being "value". row key is your row key. --- Chris Lohfink On Jul 17, 2014, at 6:32 PM, Clint Kelly wrote: > Hi everyone, >=20 > I am trying to design a schema that will keep the N-most-recent > versions of a value. Currently my table looks like the following: >=20 > CREATE TABLE foo ( > rowkey text, > family text, > qualifier text, > version long, > value blob, > PRIMARY KEY (rowkey, family, qualifier, version)) > WITH CLUSTER ORDER BY (rowkey ASC, family ASC, qualifier ASC, version = DESC)); >=20 > Is there any standard design pattern for updating such a layout such > that I keep the N-most-recent (version, value) pairs for every unique > (rowkey, family, qualifier)? I can't think of any way to do this > without doing a read-modify-write. The best thing I can think of is > to use TTL to approximate the desired behavior (which will work if I > know how often we are writing new data to the table). I could also > use "LIMIT N" in my queries to limit myself to only N items, but that > does not address any of the storage-size issues. >=20 > In case anyone is curious, this question is related to some work that > I am doing translating a system built on HBase (which provides this > "keep the N-most-recent-version-of-a-cell" behavior) to Cassandra > while providing the user with as-similar-as-possible an interface. >=20 > Best regards, > Clint