How to get binary data into integer on mapreduce in riak

74 views Asked by At

I am working on riak-erlang client ,

I have done the following...

3> Mapf = fun(Obj,_,_) -> [riak_object:get_value(Obj)] end.
#Fun<erl_eval.18.82930912>
4> 
4>  {ok, [{0,[R]}]} = riakc_pb_socket:mapred(Pid,<<"tst">>, [{map{qfun,Mapf},none,true}]).    
** exception error: no match of right hand side value {ok,[{0,[<<"2">>,<<"4">>,<<"6">>,<<"3">>,<<"5">>,<<"1">>]}]}

How to solve this issue

and also how to solve these kind of issue

{ok, [{0,[S]}]} = riakc_pb_socket:mapred(Pid,<<"test">>,[{map,  {qfun,Maps},none,true}]).   
** exception error: no match of right hand side value {ok,[{0,
                                                        [<<"{\"age\": 24, \"name\": \"krishna\"}">>,
                                                         <<"{\"age\": 29, \"name\": \"sharat\"}">>,
                                                         <<"{\"age\": 27, \"name\": \"anil\"}">>,
                                                         <<"{\"age\": 28, \"name\": \"kumar\"}">>,
                                                         <<"{\"age\": 24, \"name\": \"gopi\"}">>,
                                                         <<"{\"age\": 25, \"name\": \"ramesh\"}">>]}]}

if i want to get only age , where the age was even. how to write the map function.

1

There are 1 answers

0
fenollp On

You have pattern matching issues. You try both times to match a list using [R] = [<<data…>>,…].

[R] actually matches a 1-element list, the element being R.
You need to remove those brackets to match the whole data structure, like so: {ok, [{0,R}].