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 B8D20D842 for ; Sat, 29 Sep 2012 19:26:01 +0000 (UTC) Received: (qmail 98148 invoked by uid 500); 29 Sep 2012 19:25:59 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 98126 invoked by uid 500); 29 Sep 2012 19:25: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 98118 invoked by uid 99); 29 Sep 2012 19:25:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Sep 2012 19:25:59 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,MIME_QP_LONG_LINE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [63.146.121.108] (HELO mail.venarc.com) (63.146.121.108) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Sep 2012 19:25:53 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.venarc.com (Postfix) with ESMTP id 9CD9D6F00002 for ; Sat, 29 Sep 2012 12:25:32 -0700 (PDT) X-Virus-Scanned: amavisd-new at venarc.com Received: from mail.venarc.com ([127.0.0.1]) by localhost (mail.venarc.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id db-Ha9A2r5+Z for ; Sat, 29 Sep 2012 12:25:29 -0700 (PDT) Received: from [192.168.1.5] (drew-home [108.60.62.58]) by mail.venarc.com (Postfix) with ESMTPSA id CD05B6F00001 for ; Sat, 29 Sep 2012 12:25:29 -0700 (PDT) Subject: Re: Data Modeling: Comments with Voting References: <50639F7D.5080004@mustardgrain.com> From: Drew Kutcharian Content-Type: multipart/alternative; boundary=Apple-Mail-B4B875D7-380B-4D77-A982-F9B94AAFBC00 X-Mailer: iPad Mail (9B206) In-Reply-To: Message-Id: <360B2221-3DA3-46A1-BF28-8EA50DF56A22@venarc.com> Date: Sat, 29 Sep 2012 12:25:31 -0700 To: "user@cassandra.apache.org" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (1.0) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-B4B875D7-380B-4D77-A982-F9B94AAFBC00 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Thanks Roshni, I'm not sue how #d will work when users are actually voting on a comment. Wh= at happens when two users vote on the same comment simultaneously? How do yo= u update the entries in #d column family to prevent duplicates? Also #a and #c can be combined together using TimeUUID as comment ids. - Drew On Sep 27, 2012, at 2:13 AM, Roshni Rajagopal = wrote: > Hi Drew, >=20 > I think you have 4 requirements. Here are my suggestions. >=20 > a) store comments : have a static column family for comments with master d= ata like created date, created by , length etc > b) when a person votes for a comment, increment a vote counter : have a co= unter column family for incrementing the votes for each comment > c) display comments sorted by date created: have a column family with a du= mmy row id 'sort_by_time_list', column names can be date created(timeUUID)= , and column value can be comment id=20 > d) display comments sorted by number of votes: have a column family with a= dummy row id 'sort_by_votes_list' and column names can be a composite of nu= mber of votes , and comment id ( as more than 1 comment can have the same vo= tes) >=20 >=20 > Regards, > Roshni >=20 > > Date: Wed, 26 Sep 2012 17:36:13 -0700 > > From: kirk@mustardgrain.com > > To: user@cassandra.apache.org > > CC: drew@venarc.com > > Subject: Re: Data Modeling: Comments with Voting > >=20 > > Depending on your needs, you could simply duplicate the comments in two=20= > > separate CFs with the column names including time in one and the vote in= =20 > > the other. If you allow for updates to the comments, that would pose=20 > > some issues you'd need to solve at the app level. > >=20 > > On 9/26/12 4:28 PM, Drew Kutcharian wrote: > > > Hi Guys, > > > > > > Wondering what would be the best way to model a flat (no sub comments,= i.e. twitter) comments list with support for voting (where I can sort by cr= eate time or votes) in Cassandra? > > > > > > To demonstrate: > > > > > > Sorted by create time: > > > - comment 1 (5 votes) > > > - comment 2 (1 votes) > > > - comment 3 (no votes) > > > - comment 4 (10 votes) > > > > > > Sorted by votes: > > > - comment 4 (10 votes) > > > - comment 1 (5 votes) > > > - comment 2 (1 votes) > > > - comment 3 (no votes) > > > > > > It's the sorted-by-votes that I'm having a bit of a trouble with. I'm l= ooking for a roll-your-own approach and prefer not to use secondary indexes a= nd CQL sorting. > > > > > > Thanks, > > > > > > Drew > > > > >=20 --Apple-Mail-B4B875D7-380B-4D77-A982-F9B94AAFBC00 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Thanks Roshni,
<= br>
I'm not sue how #d will work when users are actually voting on= a comment. What happens when two users vote on the same comment simultaneou= sly? How do you update the entries in #d column family to prevent duplicates= ?

 Also #a and #c can be combined together usi= ng TimeUUID as comment ids.

- Drew



On Sep 27, 2012, at 2:13 AM, Roshni Rajagopal <roshni_rajagopal@hotmail.com> wrote:<= br>
Hi Drew,

I think you have 4 requirements. Here are my sug= gestions.

a) store comments : have a static column f= amily for comments with master data like created date, created by , length e= tc
b) when a person votes for a comment, increment a vote counter := have a counter column family for incrementing the votes for each comment
c) display comments sorted by date created: have a column family wit= h a dummy row id  'sort_by_time_list',  column names can be date c= reated(timeUUID), and column value can be comment id 
d) disp= lay comments sorted by number of votes: have a column family with a dummy ro= w id 'sort_by_votes_list' and column names can be a composite of number of v= otes , and comment id ( as more than 1 comment can have the same votes)


Regards,
Roshni

> Date: Wed, 26 Sep 2012 17:36:13 -07= 00
> From: kirk@mustardgrain.= com
> To: user@cassan= dra.apache.org
> CC: drew@venar= c.com
> Subject: Re: Data Modeling: Comments with Voting
> <= br>> Depending on your needs, you could simply duplicate the comments in t= wo
> separate CFs with the column names including time in one and the= vote in
> the other. If you allow for updates to the comments, that w= ould pose
> some issues you'd need to solve at the app level.
>=
> On 9/26/12 4:28 PM, Drew Kutcharian wrote:
> > Hi Guys,> >
> > Wondering what would be the best way to model a fla= t (no sub comments, i.e. twitter) comments list with support for voting (whe= re I can sort by create time or votes) in Cassandra?
> >
> &g= t; To demonstrate:
> >
> > Sorted by create time:
> &= gt; - comment 1 (5 votes)
> > - comment 2 (1 votes)
> > - c= omment 3 (no votes)
> > - comment 4 (10 votes)
> >
>= > Sorted by votes:
> > - comment 4 (10 votes)
> > - co= mment 1 (5 votes)
> > - comment 2 (1 votes)
> > - comment 3= (no votes)
> >
> > It's the sorted-by-votes that I'm havi= ng a bit of a trouble with. I'm looking for a roll-your-own approach and pre= fer not to use secondary indexes and CQL sorting.
> >
> > T= hanks,
> >
> > Drew
> >
>
=
= --Apple-Mail-B4B875D7-380B-4D77-A982-F9B94AAFBC00--