You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Wout Mertens <wm...@cisco.com> on 2009/02/05 16:14:18 UTC

Re: [user] Re: Reduce to nothing

I think the whole point of map/reduce is that you map/reduce tells you  
"ok anything you can do with this model is ok and fast. Anything you  
can't do with this model you'll have to work around in your  
application because it can't be implemented in a scalable way".

No?

Wout.

On Feb 5, 2009, at 4:00 PM, Michael Marks wrote:

> How about having a third attribute "state": with possible values  
> "active", "cancelled" and filtering about this one?
>
> ________________________________________
> Michael Marks
>
>
>
>
> Matt Goodall schrieb:
>> 2009/2/5 Jeremy Wall <jw...@google.com>:
>>
>>> Can't you just have the map screen out the cancellations? Seems  
>>> like that's
>>> the most natural spot for the behaviour you want.
>>>
>>
>> Nope, because the "thing" doesn't know it's been cancelled.
>>
>> - Matt
>>
>>
>>
>>> On Feb 5, 2009 8:34 AM, "Matt Goodall" <ma...@gmail.com>  
>>> wrote:
>>>
>>> Hi,
>>>
>>> Is it possible to reduce a key to nothing, i.e. completely remove a
>>> key from the reduction result.
>>>
>>> For instance, say you post three documents:
>>>
>>>  {"_id": "thing1", "type": "thing"}
>>>  {"_id": "thing2", "type": "thing"}
>>>  {"_id": "...", "type": "cancellation", "cancels": "thing1"}
>>>
>>> It's trivial to produce a map function that collates the "thing" and
>>> "cancellation" documents. However, I can't work out how, or even it
>>> it's possible, to reduce the view that so that only "thing2"  
>>> remains.
>>>
>>> This seems like it might be a useful thing to be able to do at  
>>> times.
>>> For instance, posting a "cancellation" document effectively  
>>> removes a
>>> "thing" from the database. Nothing needs to touch the "thing",
>>> avoiding any chance of conflicts and it doesn't matter how many
>>> "cancellation" documents get posted making cancellation an  
>>> idempotent
>>> operation.
>>>
>>> I tried not returning anything, just in case it worked ;-), but  
>>> got a
>>> JSON encoding error (can't encode undefined, iirc). That would be a
>>> simple approach. However, I wondered if the more "normal" approach  
>>> of
>>> allowing a reduce function to emit zero or more (key, value) pairs
>>> would be even better? Not sure if that would break the incremental
>>> reduce though.
>>>
>>> Any ideas, or is there another way to achieve this that I'm missing?
>>>
>>> - Matt
>>>
>>>
>>
>>