incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Anderson <jch...@apache.org>
Subject Re: helper functions in reduce
Date Wed, 11 Mar 2009 01:29:03 GMT
On Tue, Mar 10, 2009 at 6:18 PM, kowsik <kowsik@gmail.com> wrote:
> And the source code as defined in the view is parsed and executed
> __each__ time reduce is called on the changed docs. I think the intent
> was that the view server has no clue when _design views actually
> change. So couchdb passes in the actual string corresponding to the
> view function each time it wants couchjs to reduce a bunch of
> key/values. I suppose you could precompile these functions in the view
> server and have it return "handles" to couchdb that can be used at a
> later stage.

We've discussed a little on IRC, how to optimize this. The plan so
far, is to maintain in CouchDB's ets tables of couchjs processes, a
list of functions known by each process (where functions are named by
their md5 hash). When a function is passed to a query server, it'll be
passed along with its name, the first time. If a server already knows
about the function, Couch will just pass the name in subsequent
requests. If they somehow get out of sync CouchDB can just kill that
server and start fresh.

This also means that if you have lots of dbs with the same views in
them, you get nice reuse of couchjs processes.

Anyone feel like implementing? ;)

Chris


-- 
Chris Anderson
http://jchris.mfdz.com

Mime
View raw message