Erlang Map Reduce Example and Multiple Objects

Ted Karmel ted.karmel at
Mon May 10 11:06:27 EDT 2010


I am following the Erlang Map Reduce example found here:

I completed the example successfully with the intended result.

But, initially, I received an unintended result when creating a
separate object for each value:

>  O0 = riak_object:new(<<"groceries">>, <<"mine">>, ["bread"]).
>  Client:put(O0, 1).
>  O1 = riak_object:new(<<"groceries">>, <<"mine">>, ["cheese"]).
>  Client:put(O1, 1).
>  O2 = riak_object:new(<<"groceries">>, <<"yours">>, ["bread"]).
>  Client:put(O2, 1).
>  O3 = riak_object:new(<<"groceries">>, <<"yours">>, ["butter"]).
>  Client:put(O3, 1).

The result was:

>  [{"bread", 2}]

and not

>  [{"cheese", 1}, {"bread", 2}, {"butter", 1}]

My question is WHY is there a difference?  If you enter multiple
values via multiple objects for the same bucket and key, do the map
reduce functions not operate over all of the values?

Any insights much appreciated.

More information about the riak-users mailing list