Re: Datamodel for a highscore list

2014-01-24 Thread Kasper Middelboe Petersen
Is this a non-CQL trick? If not, then would it be possible for you to give me the CQL3 CREATE TABLE definition instead? I'm not entirely sure what you mean by "UserId, UserId, UserScore:Score" and then FriendId, Score, etc. On Thu, Jan 23, 2014 at 5:06 PM, Colin Clark wrote: > One of tricks I'

Re: Datamodel for a highscore list

2014-01-23 Thread Colin Clark
One of tricks I've used a lot with cassandra is a sparse df definition and inserted columns programmatically that weren't in the definition. I'd be tempted to look at putting a users friend list on one row, the row would look like this: ROWIDCOLUMNS UserID UserId, UserID, UserSco

Re: Datamodel for a highscore list

2014-01-23 Thread Colin Clark
Most of the work I've done like this has used sparse table definitions and the empty column trick. I didn't explain that very well in my last response. I think by using the userid as the rowid, and using the friend id as the column name with the score, that I would put an entire user's friend lis

Re: Datamodel for a highscore list

2014-01-23 Thread Kasper Middelboe Petersen
What would the consequence be of having this updated highscore table (using friendId as part of the clustering index to avoid name collisions): CREATE TABLE highscore ( userId uuid, score int, friendId uuid, name varchar, PRIMARY KEY(userId, score, friendId) ) WITH CLUSTERING ORDER BY (s

Re: Datamodel for a highscore list

2014-01-22 Thread Colin
One way might be to use userid as a rowid, and then put all of the friends with their scores on the same row. You could even update the column entry like this Score:username or Id This way the columns would come back sorted when reading the high scores for the group. To update set that uses s

Re: Datamodel for a highscore list

2014-01-22 Thread Kasper Middelboe Petersen
Many million users. Just the one game- I might have some different scores I need to keep track of, but I very much hope to be able to use the same approach for those as for the high score mentioned here. On Wed, Jan 22, 2014 at 7:08 PM, Colin Clark wrote: > How many users and how many games? >

Re: Datamodel for a highscore list

2014-01-22 Thread Kasper Middelboe Petersen
Yes friendship is symmetrical. This could work for my problem right now, but I'm afraid it would just be postponing the problem slightly until something like big tournaments (which are coming) raises the same problem again. On Wed, Jan 22, 2014 at 6:58 PM, Jon Ribbens < jon-cassan...@unequivocal

Re: Datamodel for a highscore list

2014-01-22 Thread Colin Clark
How many users and how many games? -- Colin +1 320 221 9531 On Jan 22, 2014, at 10:59 AM, Kasper Middelboe Petersen < kas...@sybogames.com> wrote: I can think of two cases where something bad would happen in this case: 1. Something bad happens after the increment but before some or all of the

Re: Datamodel for a highscore list

2014-01-22 Thread Edward Capriolo
It is a tricky type of problem because some ways of doing it involve iterative scans. This presentation discusses a solution for top-k: http://www.slideshare.net/planetcassandra/jonathan-halliday On Wed, Jan 22, 2014 at 12:48 PM, Colin wrote: > Read users score, increment, update friends list,

Re: Datamodel for a highscore list

2014-01-22 Thread Kasper Middelboe Petersen
I can think of two cases where something bad would happen in this case: 1. Something bad happens after the increment but before some or all of the update friend list is finished 2. Someone spams two scores at the same time creating a race condition where one of them could have a score that is not y

Re: Datamodel for a highscore list

2014-01-22 Thread Jon Ribbens
On Wed, Jan 22, 2014 at 06:44:20PM +0100, Kasper Middelboe Petersen wrote: >I'm a little worried about the data model I have come up with for handling >highscores. >I have a lot of users. Each user has a number of friends. I need a >highscore list pr friend list. >I would like t

Re: Datamodel for a highscore list

2014-01-22 Thread Colin
Read users score, increment, update friends list, update user with new high score Would that work? -- Colin +1 320 221 9531 > On Jan 22, 2014, at 11:44 AM, Kasper Middelboe Petersen > wrote: > > Hi! > > I'm a little worried about the data model I have come up with for handling > highsc