Map Reduce with Python

Sean Cribbs sean at basho.com
Thu Jun 14 09:11:16 EDT 2012


Matt,

Add {'keep':true} to your final reduce phase.

On Wed, Jun 13, 2012 at 12:04 AM, Matt Black <matt.black at jbadigital.com>wrote:

> Hello list,
>
> In an M/R query, I'd like to be able to merge objects from two different
> buckets in my output. So my process is a map phase for each bucket, with a
> link phase in the middle, and a reduce phase to do a bit of merge
> processing at the end.
>
> client = riak.RiakClient(RIAK_HOST, RIAK_PORT)
> query = client.add("carts")
> query.map("function(v) { return [[ v.bucket, v.key,
> Riak.mapValuesJson(v)[0] ]]; }", {'keep': False})
> query.link("cart-products", "cart-products", False)
> query.link("products", "product", False)
> query.map("function(v) { return [ Riak.mapValuesJson(v)[0] ]; }", {'keep':
> False})
> query.reduce("function(values) { return values; }")
>
> This query will return only objects from the "products" bucket.
>
> I tried using the "keep" flags on each map phase, but in this case the I
> get output from each map phase and the reduce phase appears to be ignored -
> which is somewhat unexpected.
>
> Please advise on changes or things I could try.
>
> Thanks
>
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>


-- 
Sean Cribbs <sean at basho.com>
Software Engineer
Basho Technologies, Inc.
http://basho.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20120614/2ce47a45/attachment.html>


More information about the riak-users mailing list