You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Tom McNulty <to...@cetiforge.com> on 2009/03/29 03:29:58 UTC

Reduce Assumptions

Hello,

Can we assume that values sent to the reduce functions, are sorted in  
the order of their associated keys? From my experiments it appears to  
be true, but is this likely to change in the future?

Incase I'm not asking the right question, here's what I'm trying to do.

my map function produces output like:

[X, Y, 0]  -> Object_A
[X, Y, 1]  -> Object_B1
[X, Y, 1]  -> Object_B1
[X, Y, 1]  -> Object_B1
[Z, Q, 0] ....

Here I apply group_level=2, and use a ranged query ( [X, 0] to [X,  
[] ] )  since Y >= 0


Now during the reduce phase, I combine together Object_A's and  
associated Object_B's. Can I assume that the first of the values sent  
to 'reduce' is Object_A? Furthermore, if a rereduce is required, will  
the first 'rereduced' value be the 'left most' object produced during  
the previous reduction.  In other words, does the reduce function fold  
left over it's input data?


Thanks for reading this,

- Tom


Re: Reduce Assumptions

Posted by Tom McNulty <to...@cetiforge.com>.
Sorry not sure why that sent twice.

Yes please do add this answer to the wiki. As a person new to CouchDB,  
I found the reduce stage to be the most mysterious.  This is of course  
quite good, since it forces users to think about the data structures  
involved. At this level, you're likely to have a much better  
understanding of your database, than a typical (blackbox) SQL user.

  Perhaps a diagram showing a reduce operation, progressing through  
subtrees would be quite illustrative?

- Tom