How can I retrieve names from the ranking?

111 views
Skip to first unread message

Rob

unread,
Jan 7, 2013, 3:01:35 PM1/7/13
to google-app-en...@googlegroups.com
My use case is "given an user with score x, find n users that are immediately under and over him in the ranking".
I though about doing this:
    y = FindRank(x);
    scores = FindScoreApproximate(z) where z = [y-n; y+n].
That would leave me with a bunch of scores. Now how do I get the users from these scores? I know how to do it if I had another datastore with users and scores, but I know these user ids are being stored in the ranklist when I SetScore(name, score), so how do I retrieve these names?

Thank you

Bartholomew Furrow

unread,
Jan 7, 2013, 6:44:26 PM1/7/13
to google-app-en...@googlegroups.com
There isn't currently a way to do that.  You could add a function of your own to do a datastore Query for those people.  It isn't really intended to be indexed in that way.  Still, you could change it so that leaf nodes contain a list of strings with that score.

In Code Jam, the ranker is secondary to scoreboard_rows.  If you want the first few people below person X, you get X's score and query for lower scores, sorting descending.  If you want the first few people below rank Y, you get the score from rank Y and query in the same way.

I hope that helps!
Bartholomew

--
You received this message because you are subscribed to the Google Groups "Google App Engine Ranklist" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-app-engine-ranklist/-/9xZeZJpbuPYJ.
To post to this group, send email to google-app-en...@googlegroups.com.
To unsubscribe from this group, send email to google-app-engine-r...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-app-engine-ranklist?hl=en.

Rob

unread,
Jan 8, 2013, 6:58:53 AM1/8/13
to google-app-en...@googlegroups.com
Thank you for your answer. Yes, that helps. I just don't get one thing: when I insert a score with same name but other value, it updates the value (i.e., erases the old one). So the information (the name) is already there, why can't I retrieve?

Roberto Caldas

unread,
Jan 8, 2013, 7:38:11 AM1/8/13
to google-app-en...@googlegroups.com
By the way, in Code Jam, don't you want to know the rank of those people below person X? Do you query for lower scores and use FindRanks? 


--
You received this message because you are subscribed to the Google Groups "Google App Engine Ranklist" group.

Bartholomew Furrow

unread,
Jan 9, 2013, 12:29:17 PM1/9/13
to google-app-en...@googlegroups.com

The information is there, but not convenient. It's like there's a hash table mapping from name to score. The mapping from score to names exists in principle, but is hard to get at in practice.

--
You received this message because you are subscribed to the Google Groups "Google App Engine Ranklist" group.

Bartholomew Furrow

unread,
Jan 9, 2013, 12:31:46 PM1/9/13
to google-app-en...@googlegroups.com

I don't need the ranker at all to find people with lower score than person X. I look up X's score in his scoreboard row entity, and then query for scoreboard row entities with smaller scores (sorting descending by score).

Roberto Caldas

unread,
Jan 9, 2013, 12:40:16 PM1/9/13
to google-app-en...@googlegroups.com
Ok, thank you. I meant a little bit different: don't you need the rank (the position in the ranking) of those people with lower score than person X?
Well I need, so I do what you do and then I use FindRanks passing the result of the query in scoreboard as input, but I'm not convinced that's the best way to do it. 

Bartholomew Furrow

unread,
Jan 9, 2013, 1:03:40 PM1/9/13
to google-app-en...@googlegroups.com

Ah, I see. For that we find the rank R of X using the ranker, then assume the first person returned by the query has rank R+1, etc., with special logic for dealing with ties. FindRanks would work too, but it's an unnecessary datastore call.

Reply all
Reply to author
Forward
0 new messages