incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Prater <steph...@agrussell.com>
Subject Re: Reduce function to perform a Union?
Date Fri, 20 May 2011 13:59:32 GMT
Why do you need to reduce those docs?  In this particular exmple, you  
can do a range query on the key and get the same (basically) results.

Also, I think the growth rate for reduce functions is log(rows) - so  
reducing the view size by 50% is still going to run up against the  
limit.

On May 19, 2011, at 9:41 PM, Jim Klo wrote:

> I'm a little dumbfounded by reduce functions.
>
> What I'm trying to do is take a view that has heterogeneous values  
> and union into a single object; logically this seems like what the  
> reduce function should be capable of doing, but it seems I keep  
> getting the reduce overflow error. Effectively I'm reducing the view  
> by 50%.
>
> Consider the the simplistic scenario:
>
> doc A: { _id : "abc123", type:"resource", keyword:"nasa" }
> doc B: { _id : "abc123-timestamp", type: "timestamp", timestamp:  
> "2011/05/19T12:00:00.0000Z", ref_doc: "abc123" }
> doc N: ....
>
> Doc A is the original doc... Doc B is the timestamp doc referencing  
> Doc A via ref_doc field... Doc N is just another doc also  
> referencing Doc A via ref_doc field.
>
> I can create a view that essentially looks like:
>
> Key				Value
> ------------		------------------
> "abc123"		{ .... doc A object .... }
> "abc123"		{ .... doc B object .... }
> "abc123"		{ .... doc N object .... }
>
> I would expect I could build a reduced view that looks something  
> like this:
>
> Key				Value
> ------------		------------------
> "abc123"		{ .... merged doc .... }
>
> Ultimately this goes back to an issue we have where we need the node  
> local timestamp of a document, without generating an event that  
> would cause an update to doc A, causing it to get replicated. We  
> figure we can store local data like a timestamp then join it back  
> with the original doc via a view & list.
>
> Is there something magical about the reduce that's not well  
> documented? Or maybe is there a better way to do this?  I know about  
> using linked docs, were in my map function you can reference the _id  
> of the linked document in the value you can return @ 1 - 1 merge  
> with the include_docs=true, but don't think I can do that with N  
> docs; or can I?
>
> Jim Klo
> Senior Software Engineer
> Center for Software Engineering
> SRI International
>
>
>
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message