Map Reduce with Python

Matt Black matt.black at jbadigital.com
Wed Jun 13 00:04:18 EDT 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20120613/041f9a4a/attachment.html>


More information about the riak-users mailing list