Getting top N players

57 views
Skip to first unread message

Neil Ghosh

unread,
Oct 22, 2014, 5:41:52 AM10/22/14
to google-app-en...@googlegroups.com
I am using the Java version of this and need to retrieve the top N players with highest scores.

One solution is just to fetch the top N "ranker_score" entities order by the value. However this would need an index on the value attribute of "ranker_score" entity.

Using objectify

return ofy().load().type( ranker_score.class ).order( "-value" ).limit( N ).list();

is the a scalable solution or we could avoid the index by traversing the tree from the right side ? In the later case getting the player_name would be difficult.

Bartholomew Furrow

unread,
Oct 27, 2014, 11:29:00 PM10/27/14
to google-app-en...@googlegroups.com

Your idea should work as well as anything for retrieving the top N, and you won't need an index because you're only querying for one property. Two thoughts:
- Make sure you use an ancestor query based on the root key in case you ever make a second ranker
- In Code Jam, all the ranker does for us is return the score of the Nth person. The actual information we want is in a totally separate set of objects. So if we want the top N "scoreboard_row" Entities, we just query for scoreboard rows, sorting by score descending. If we want the next N, we ask the ranker for the score of the person in Nth and then query for scoreboard rows, with score <= score(Nth), and sorting by score descending.


--
You received this message because you are subscribed to the Google Groups "Google App Engine Ranklist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-app-engine-r...@googlegroups.com.
To post to this group, send email to google-app-en...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-app-engine-ranklist.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages