Skip to content

Instantly share code, notes, and snippets.

@SeanOC
Created August 5, 2011 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanOC/1128505 to your computer and use it in GitHub Desktop.
Save SeanOC/1128505 to your computer and use it in GitHub Desktop.
(vagrant@127.0.0.1)1> {ok, Client} = riak:client_connect('riak@10.0.2.15').
{ok,{riak_client,'riak@10.0.2.15',<<3,172,224,28>>}}
(vagrant@127.0.0.1)2> {ok, [R]} = Client:mapred([{<<"groceries">>, <<"mine">>},
(vagrant@127.0.0.1)2> {<<"groceries">>, <<"yours">>}],
(vagrant@127.0.0.1)2> [{'map', {modfun, triggers, count}, 'none', false},
(vagrant@127.0.0.1)2> {'reduce', {modfun, triggers, merge}, 'none', true}]).
** exception error: no match of right hand side value {error,{error,undef,
[{triggers,count,
[{r_object,<<"groceries">>,<<"mine">>,
[{r_content,{dict,2,16,16,8,80,48,
{[],[],[],[],...},
{{[],[],...}}},
["eggs","bacons"]}],
[{<<7,251,249,244>>,{1,63479791411}}],
{dict,1,16,16,8,80,48,{[],[],[],[],[],...},{{[],[],[],...}}},
undefined},
undefined,none]},
{riak_kv_mapper,run_map,9},
{riak_kv_mapper,'-do_map/2-fun-0-',9},
{lists,foldl,3},
{riak_kv_mapper,do_map,2},
{gen_fsm,handle_msg,7},
{proc_lib,init_p_do_apply,3}]}}
-module(triggers).
-export([count/3, merge/2]).
count(G, _, _) ->
[dict:from_list([{I, 1} || I <- riak_object:get_value(G)])].
merge(Gcounts, _) ->
[lists:foldl(fun(G, Acc) ->
dict:merge(fun(_, X, Y) -> X+Y end,
G, Acc)
end,
dict:new(),
Gcounts)].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment