On Mon, Dec 22, 2008 at 1:00 PM, newb <[email protected]> wrote: > I have an entity "book" and for each book you can "vote it up". For > the voting aspect, I use a sharded counter as has been recommended > here. But now I'm wondering how I can efficiently return my list of > books ordered by their vote. Is there an obvious implementation vs. > more advanced techniques?
That's not going to be a good use for a sharded counter. The point of sharding a counter is to cut down on the write contention by sharding it across multiple counters. That works well if you only want to find aggregate values for a single counter key. One approach might be to periodically evaluate the counter and save it to the relevant book entry. That's no good if you need the value to be exactly correct for sorting purposes, but it would probably work well enough if you just want to be able to make a top 10 list, and you can do a re-evaluation (and re-sort) when generating the list. Other than that, consider not using a sharded counter at all. It only helps if there's significant write contention on the counter (say if lots of people are simultaneously voting on a *single* book). If that's not likely to be the case, just put the counter in the book entity itself, and then it will be trivial to sort a book list by the number of votes. Dave. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
