Created
November 12, 2012 20:49
-
-
Save blinkov/4061784 to your computer and use it in GitHub Desktop.
Erlang Multiget Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(riak). | |
-author("Ivan Blinkov <[email protected]>"). | |
-export([multiget/3]). | |
multiget(Pid, Bucket, Keys) -> | |
case riakc_pb_socket:mapred(Pid, | |
[{Bucket, Key} || Key <- Keys], | |
[ | |
{reduce, | |
{modfun, riak_kv_mapreduce, reduce_set_union}, none, false}, | |
{map, | |
{modfun, riak_kv_mapreduce, map_identity}, none, true} | |
]) of | |
{ok,[{_,List}|_]} -> | |
{ok, | |
[new(Bucket, Key, Value) || | |
{r_object, _Bucket, Key, | |
[{r_content, _Meta, Value}], | |
_VClock, _UpdateMeta, _UpdateVal} <- List]}; | |
{error,notfound} -> | |
[]; | |
Other -> | |
Other | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you write "money denomination" code in erlang Language ?