Skip to content

Instantly share code, notes, and snippets.

@seth
Created September 2, 2010 18:17
Show Gist options
  • Select an option

  • Save seth/562656 to your computer and use it in GitHub Desktop.

Select an option

Save seth/562656 to your computer and use it in GitHub Desktop.
109> Merge = fun(VL, _A) ->
109> [ lists:foldl(fun(X, Acc) -> X + Acc end, 0, VL) ]
109> end.
#Fun<erl_eval.12.113037538>
110>
110> Length = fun(G, _X, _Y) ->
110> [ size(riakc_obj:get_value(G)) ]
110> end.
#Fun<erl_eval.18.105910772>
111>
111> Dates = [
111> <<"2004-09-16">>, <<"2004-09-15">>, <<"2004-09-14">>,
111> <<"2004-09-13">>, <<"2004-09-10">>, <<"2004-09-09">>,
111> <<"2004-09-08">>, <<"2004-09-07">>, <<"2004-09-03">>,
111> <<"2004-09-02">>, <<"2004-09-01">>, <<"2004-08-31">>,
111> <<"2004-08-30">>
111> ].
[<<"2004-09-16">>,<<"2004-09-15">>,<<"2004-09-14">>,
<<"2004-09-13">>,<<"2004-09-10">>,<<"2004-09-09">>,
<<"2004-09-08">>,<<"2004-09-07">>,<<"2004-09-03">>,
<<"2004-09-02">>,<<"2004-09-01">>,<<"2004-08-31">>,
<<"2004-08-30">>]
112>
112> Inputs = [ {<<"goog">>, D} || D <- Dates ].
[{<<"goog">>,<<"2004-09-16">>},
{<<"goog">>,<<"2004-09-15">>},
{<<"goog">>,<<"2004-09-14">>},
{<<"goog">>,<<"2004-09-13">>},
{<<"goog">>,<<"2004-09-10">>},
{<<"goog">>,<<"2004-09-09">>},
{<<"goog">>,<<"2004-09-08">>},
{<<"goog">>,<<"2004-09-07">>},
{<<"goog">>,<<"2004-09-03">>},
{<<"goog">>,<<"2004-09-02">>},
{<<"goog">>,<<"2004-09-01">>},
{<<"goog">>,<<"2004-08-31">>},
{<<"goog">>,<<"2004-08-30">>}]
113>
113>
113> [Length(erlang:element(2, riakc_pb_socket:get(RiakPid, B, K)), a, b)|| {B, K} <- Inputs].
["r","r","r","r","r","r","r","q","q","p","q","r","r"]
114>
114> riakc_pb_socket:mapred(RiakPid, Inputs, [{map, {qfun, Length}, none, true}]).
{ok,[{0,
[{not_found,{<<"goog">>,<<"2004-09-16">>},undefined},
{not_found,{<<"goog">>,<<"2004-09-15">>},undefined},
{not_found,{<<"goog">>,<<"2004-09-14">>},undefined},
{not_found,{<<"goog">>,<<"2004-09-13">>},undefined},
{not_found,{<<"goog">>,<<"2004-09-10">>},undefined},
{not_found,{<<"goog">>,<<"2004-09-08">>},undefined},
{not_found,{<<"goog">>,<<"2004-09-09">>},undefined},
{not_found,{<<"goog">>,<<"2004-09-03">>},undefined},
{not_found,{<<"goog">>,<<"2004-09-07">>},undefined},
{not_found,{<<"goog">>,<<"2004-09-02">>},undefined},
{not_found,{<<"goog">>,<<"2004-09-01">>},undefined},
{not_found,{<<"goog">>,<<"2004-08-31">>},undefined},
{not_found,{<<"goog">>,<<"2004-08-30">>},undefined}]}]}
115>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment