Hi, I got it. very much thanks,one more doubt please clarify it.
same thing i have done for another bucket called "test" which contains data in the form of key, value. but when i do map reduce i am getting the following: {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\"}">>]}]} On Sat, May 17, 2014 at 8:21 PM, Steve Vinoski <st...@basho.com> wrote: > > > > On Sat, May 17, 2014 at 10:04 AM, Gopi Krishna <g...@lintelindia.com>wrote: > >> Hi, >> >> I am getting the following , don't know what was happening could you >> please elaborate and explain the solution to this. >> >> I am working on erlang-riak-client. >> >> >> 1> {ok, Pid} = riakc_pb_socket:start_link('127.0.0.1',10017). >> {ok,<0.34.0>} >> 2> >> 2> >> 2> Object = riakc_obj:new(<<"test_age">>, <<"test1">>, <<"gopi & 1">>). >> {riakc_obj,<<"test_age">>,<<"test1">>,undefined,[], >> undefined,<<"gopi & 1">>} >> 3> >> 3> >> 3> riakc_pb_socket:put(Pid,Object). >> ok >> 4> >> 4> Mapf = fun(Obj,_,_) -> [{I,1}|| I <- >> binary_to_term(riak_object:get_value(Object))] end. >> > > There are two problems with your Mapf function: > > 1. The body of the function incorrectly uses Object, which is a variable > in your shell from command 2, rather than Obj, the incoming parameter to > the function. This is the source of the function_clause error you're > getting. > > 2. You've stored a binary value in your object, not an Erlang term, so > binary_to_term will fail here with a badarg exception. Change your Mapf > function to this instead: > > Mapf = fun(Obj,_,_) -> [riak_object:get_value(Obj)] end. > > #Fun<erl_eval.18.82930912> >> 5> {ok, [{0,[R]}]} = >> riakc_pb_socket:mapred(Pid,<<"test_age">>,[{map,{qfun,Mapf},none,true}]) >> 5> . >> ** exception error: no match of right hand side value >> {error,<<"{\"phase\":0,\"error\":\"function_clause\",\"input\":\"{ok,{r_object,<<\\\"test_age\\\">>,<<\\\"test1\\\">>,[{r_content,{dict"...>>} >> > > If you make the changes I described above, you get: > > 5> {ok, [{0,[R]}]} = > riakc_pb_socket:mapred(Pid,<<"test_age">>,[{map,{qfun,Mapf},none,true}]). > {ok,[{0,[<<"gopi & 1">>]}]} > 6> R. > <<"gopi & 1">> > > exactly as expected. > > --steve > > _______________________________________________ > riak-users mailing list > riak-users@lists.basho.com > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com > > -- Thanks & Regards, J.Gopi Krishna +91-8341452934, www.lintelindia.com Lintel Technologies Pvt. LTD,Hyderabad. This message contains confidential information and is intended for recipient. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version.
_______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com