You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Jens Rantil <je...@gmail.com> on 2013/12/20 23:19:33 UTC

Ordered view reduce

Hi,

I've been playing around with CouchDB for event sourcing[1] (terminology
from DDD and CQRS). Basically I have a series of ordered events persisted
to Couch and I've been creating simple projections basic these. The ID of a
new event will be strictly greater that all previous events for its
aggregate (couch lingo: reduce).

The current implementation only supports basic projections because reduce
input order is undefined in Couch. I've heard of the plugin system. Would
ordered reduce be something that could be implemented as a plugin?

[1] http://jensrantil.github.io/bootstrapping-couchdb-as-event-store.html

Cheers,
Jens

Sent from my iPhone 6

Re: Ordered view reduce

Posted by Jens Alfke <je...@couchbase.com>.
On Dec 20, 2013, at 2:19 PM, Jens Rantil <je...@gmail.com> wrote:

> The current implementation only supports basic projections because reduce
> input order is undefined in Couch.

I _think_ that in a standard CouchDB (but not BigCouch) the rows are passed to the reduce function in ascending key order.

> I've heard of the plugin system. Would
> ordered reduce be something that could be implemented as a plugin?

Well, the ordering is left undefined because of clustered/sharded implementations like BigCouch, where the documents and index rows can be split across multiple machines. In a setup like that, I imagine ordered reduce wouldn’t scale well because it would require transferring index rows between the nodes so that a reduce function running on one node could work on a contiguous set of rows. So if you had this, you might not want it…

—Jens