incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eric casteleijn <eric.castele...@canonical.com>
Subject Re: ranking a big list
Date Sat, 06 Feb 2010 16:04:02 GMT
On 02/06/2010 08:00 AM, Mano wrote:
> Hi,
>
> I have a large list of assessment scores (of about 500k students). The
> scores can range between 0 and 200. How do I find the rank of a particular
> score? For smaller lists, I can just sort the array of scores and for each
> student's score I can get the index of their score in the sorted list. But
> how do I achieve it using mapreduce?

Not sure if it's the optimal way, but what I'd do is this:

have a map/reduce view that counts the students per score (assuming 
you've only got integer scores, this will always return at most 200 
rows), and sort those client side.

To find out the rank of a particular student, just look up their score 
in that sorted field result, and sum up all the counts of the scores 
before it.

It does mean two rather than one http call, but I don't immediately see 
a clever way of getting away with less.

Mime
View raw message