Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save seth/562649 to your computer and use it in GitHub Desktop.
% using goog data import from the "fast track"
Merge = fun(VL, _A) ->
[ lists:foldl(fun(X, Acc) -> X + Acc end, 0, VL) ]
end.
Length = fun(G, _X, _Y) ->
[ erlang:byte_size(riakc_obj:get_value(G)) ]
end.
Dates = [
<<"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">>
].
Inputs = [ {<<"goog">>, D} || D <- Dates ].
[Length(erlang:element(2, riakc_pb_socket:get(RiakPid, B, K)), a, b)|| {B, K} <- Inputs].
riakc_pb_socket:mapred(RiakPid, Inputs, [{map, {qfun, Length}, none, true}]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment