Mapred unable to find keys that use bucket types

Mikhail Pustovalov mpustovalov at
Fri Feb 6 01:30:47 EST 2015

Thank you again Christopher,
An example would be awesome! Although I really need only one line of code
that shows how to pass specific keys to mapred function to operate on (in
the case when they use bucket type).
As to my map function: it really does nothing - simply returns key-value
pairs, because I use mapred functionality to simply fetch multiple objects
in one query. Here it is:

map_kv_pairs ( Obj, _, _ ) ->
  case riak_object:is_robject(Obj) of
    true -> [ {riak_object:key(Obj), riak_object:get_value(Obj)} ] ;
    false -> []

On Fri Feb 06 2015 at 1:24:50 AM Christopher Meiklejohn <
cmeiklejohn at> wrote:

> On Feb 5, 2015, at 12:47 PM, Mikhail Pustovalov <mpustovalov at>
> wrote:
> Hi Chris,
> Thank you for the prompt reply.
> Although that is exactly what I do. I've noticed that bucket can now be
> both binary or a tuple {binary, binary} where the first element is bucket
> type and the second is bucket. And it works for put/get operations and for
> mapred_bucket which traverses the whole bucket. But what I am trying to
> achieve is traverse only specified keys and that doesn't seem to work for
> mapred queiries. Here are the commands that work:
> simple get:
> riakc_pb_socket:get(Pid,{<<"bucket_type">>,<<"bucket">>},<<key>>).
> mapred over the whole bucket:
> riakc_pb_socket:mapred_bucket(Pid, {<<"bucket_type">>,<<"bucket">>},
> [{map, {modfun, rc_mapred, map_kv_pairs}, none, true}]).
> but this one fails with the result {ok,[{0,[{error,notfound}]}]}:
> riakc_pb_socket:mapred(Pid, [{{<<"bucket_type">>,<<"bucket">>},<<key>>}],[{map,
> {modfun, rc_mapred, map_kv_pairs}, none, true}]).
> If you can run a mapred query over specified keys could you please show me
> an example?
> I can try to put together an example.
> Do you mind sharing what your map function is doing?
> - Chris
> Christopher Meiklejohn
> Senior Software Engineer
> Basho Technologies, Inc.
> cmeiklejohn at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list