couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <B.Cand...@pobox.com>
Subject Ordering of keys into reduce function
Date Wed, 13 May 2009 11:50:20 GMT
Hi,

I want to write a reduce function which, when reducing over a range of keys,
gives the minimum and maximum *key* found in that range. (*)

This could be done very easily and efficiently if I could rely on the
following two properties:

(1) keys/values passed into a first reduce are in increasing order of key

(2) reduced values passed into a re-reduce are for increasing key ranges

The question is, can I rely on both of these properties? Especially in the
re-reduce case?

If I could, then to calculate the min I only need to take the first key
passed, or the min from the first reduce value. Similarly for max, I'd take
the last key, or the max from the last reduce value.

Regards,

Brian.

(*) An alternative would be to do two queries: startkey=aaa&limit=1 and
endkey=bbb&limit=1&descending=true. I would like to avoid two queries, and
I'd also like this functionality for group_level=n, such that within each
group I know the minimum and maximum key.

Mime
View raw message