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 9B554714B for ; Fri, 23 Dec 2011 09:53:08 +0000 (UTC) Received: (qmail 80645 invoked by uid 500); 23 Dec 2011 09:53:06 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 79715 invoked by uid 500); 23 Dec 2011 09:53:00 -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 79705 invoked by uid 99); 23 Dec 2011 09:52:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Dec 2011 09:52:59 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.113.200.5] (HELO homiemail-a47.g.dreamhost.com) (208.113.200.5) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Dec 2011 09:52:53 +0000 Received: from homiemail-a47.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a47.g.dreamhost.com (Postfix) with ESMTP id 2915D284058 for ; Fri, 23 Dec 2011 01:52:32 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=thelastpickle.com; h=from :mime-version:content-type:subject:date:in-reply-to:to :references:message-id; q=dns; s=thelastpickle.com; b=mJsQnrKKg6 SBzIoBCOjj8pTj4U+3rKYgKDJinWETv/ECKmcedn9b54ymgfXkCsxIYQ4J5pjZL5 uWrvM46qkhWU20rgSOUcmEH+OBhQOFrzBpCWnfqCJxpiCQzby46qLrlh05Sy1OYq RlHcQQWw6BjxbVozfIwILQaH0XIqKDzx4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=thelastpickle.com; h=from :mime-version:content-type:subject:date:in-reply-to:to :references:message-id; s=thelastpickle.com; bh=hZx8RcGtCmPj4ceq RKjwyN0MYes=; b=stM5f9ln2lu7rgwmrjngS8nYhSimaW8Jabik3rLNlq4/g+Mm 3ZZTev7ySzWSmkEygRHCsmz/aQCsQGJE3Er7FCRfM0qayOzlt3WiJs7+QCkviVBo Q5u+OXOYzPvgVxovfLgE0Waf6rxKwVTluCJC4CbNofB6tEcHXB3F6K0+nXY= Received: from [172.16.1.4] (125-236-193-159.adsl.xtra.co.nz [125.236.193.159]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: aaron@thelastpickle.com) by homiemail-a47.g.dreamhost.com (Postfix) with ESMTPSA id 7473C284057 for ; Fri, 23 Dec 2011 01:52:31 -0800 (PST) From: aaron morton Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: multipart/alternative; boundary="Apple-Mail=_5DB9F41A-0727-4354-AAD2-10B4E8AA2F5A" Subject: Re: Counters and Top 10 Date: Fri, 23 Dec 2011 22:52:28 +1300 In-Reply-To: To: user@cassandra.apache.org References: <26412305.3252271323862291686.JavaMail.defaultUser@defaultHost> Message-Id: <34234782-77C5-4599-A52A-9D53B1FDD091@thelastpickle.com> X-Mailer: Apple Mail (2.1251.1) --Apple-Mail=_5DB9F41A-0727-4354-AAD2-10B4E8AA2F5A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 Counters only update the value of the column, they cannot be used as = column names. So you cannot have a dynamically updating top ten list = using counters. You have a couple of options. First use something like redis if that = fits your use case. Redis could either be the database of record for the = counts. Or just an aggregation layer, write the data to cassandra and = sorted sets in redis then read the top ten from redis and use cassandra = to rebuild redis if needed.=20 The other is to periodically pivot the counts into a top ten row where = you use regular integers for the column name. With only 10K users you = could do this with an process that periodically reads all the users rows = or where ever the counters are and updates the aggregate row. Depending = on data size you cold use hive/pig or whatever regular programming = language your are happy with. I guess you could also use redis to keep the top ten sorted and then = periodically dump that back to cassandra and serve the read traffic from = there. =20 Hope that helps=20 ----------------- Aaron Morton Freelance Developer @aaronmorton http://www.thelastpickle.com On 23/12/2011, at 3:46 AM, R. Verlangen wrote: > I would suggest you to create a CF with a single row (or multiple for = historical data) with a date as key (utf8, e.g. 2011-12-22) and multiple = columns for every user's score. The column (utf8) would then be the = score + something unique of the user (e.g. hex representation of the = TimeUUID). The value would be the TimeUUID of the user. >=20 > By default columns will be sorted and you can perform a slice to get = the top 10. >=20 > 2011/12/14 cbertu81@libero.it > Hi all, > I'm using Cassandra in production for a small social network (~10.000 = people). > Now I have to assign some "credits" to each user operation (login, = write post > and so on) and then beeing capable of providing in each moment the top = 10 of > the most active users. I'm on Cassandra 0.7.6 I'd like to migrate to a = new > version in order to use Counters for the user points but ... what = about the top > 10? > I was thinking about a specific ROW that always keeps the 10 most = active users > ... but I think it would be heavy (to write and to handle in = thread-safe mode) > ... can counters provide something like a "value ordered list"? >=20 > Thanks for any help. > Best regards, >=20 > Carlo >=20 >=20 >=20 --Apple-Mail=_5DB9F41A-0727-4354-AAD2-10B4E8AA2F5A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=iso-8859-1
http://www.thelastpickle.com

On 23/12/2011, at 3:46 AM, R. Verlangen wrote:

I = would suggest you to create a CF with a single row (or multiple for = historical data) with a date as key (utf8, e.g. 2011-12-22) and multiple = columns for every user's score. The column (utf8) would then be the = score + something unique of the user (e.g. hex representation of the = TimeUUID). The value would be the TimeUUID of the user.

By default columns will be sorted and you can = perform a slice to get the top 10.

2011/12/14 cbertu81@libero.it <cbertu81@libero.it>
Hi all,
I'm using Cassandra in production for a small social network (~10.000 = people).
Now I have to assign some "credits" to each user operation (login, write = post
and so on) and then beeing capable of providing in each moment the top = 10 of
the most active users. I'm on Cassandra 0.7.6 I'd like to migrate to a = new
version in order to use Counters for the user points but ... what about = the top
10?
I was thinking about a specific ROW that always keeps the 10 most active = users
... but I think it would be heavy (to write and to handle in thread-safe = mode)
... can counters provide something like a "value ordered list"?

Thanks for any help.
Best regards,

Carlo




= --Apple-Mail=_5DB9F41A-0727-4354-AAD2-10B4E8AA2F5A--