Skip to content

Commit

Permalink
updatin code on contrb site
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Phillips committed Apr 20, 2011
1 parent 907aab4 commit 9bf04db
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions function-contrib-gollum/save_reduce.textile
Expand Up @@ -11,28 +11,15 @@ This Erlang function will save the output of a map to a bucket and key (passed b
-export([save_reduce/2]).

%%Arg is a [bucket, key] combination
save_reduce(Values, Arg) ->
save_reduce([Data | _], [Bucket, Key]) ->
{ok, C} = riak:local_client(),
[Bucket, Key] = Arg,
Data = case Values of
[] ->
skip;
[V] ->
V;
V when is_list(V) ->
hd(V);
_ ->
skip
end,
if
Data =:= skip ->
[];
true ->
Json = iolist_to_binary(mochijson2:encode(Data)),
Object = riak_object:new(Bucket, Key, Json, "application/json"),
C:put(Object, 1),
[]
end.
Json = iolist_to_binary(mochijson2:encode(Data)),
Object = riak_object:new(Bucket, Key, Json, "application/json"),
C:put(Object, 1),
[];
save_reduce(_, _) ->
[].

```


0 comments on commit 9bf04db

Please sign in to comment.