Hmmm, it seems that I've found why this is happening:

http://lists.basho.com/pipermail/riak-users_lists.basho.com/2011-February/003127.html

This problem was raised before and already solved, sorry for opening it
again :)

Alin

On Fri, Jan 6, 2012 at 9:51 PM, Alin Popa <[email protected]> wrote:

> Hi Bryan,
>
> Thanks, it makes sense, indeed, I've done what you've suggested, to load
> the code within riak (using add_paths) and everything worked fine. Still, I
> have a couple dilemas regarding this:
>
> 1. Why is not complaining if using escript instead of compiling it as a
> separate module (and no, I'm not loading the code within riak this time) ?
>
> *#!/usr/bin/env escript*
> *
> *
> *main([]) ->*
> *  code:add_patha("/Users/alin/riak-erlang-client/ebin"),*
> *  code:add_patha("/Users/alin/riak-erlang-client/deps/protobuffs/ebin"),*
> *  {ok, Pid} = riakc_pb_socket:start_link("127.0.0.1", 8087),*
> *  Fun = fun(Object, _KeyData, none) -> [Object] end,*
> *  io:format("Result: ~n~p~n",[riakc_pb_socket:mapred(Pid,
> {<<"test-bucket">>,[]}, [{map, {qfun, Fun}, none, true}])]).*
>
> this might be an erlang thing ?
>
> 2. I remember that running exactly the same code in the past (~ 1 month
> ago), worked with no special intervention like adding code paths to riak.
> In fact, that's why I've raised this problem now, as it doesn't make any
> sense. Noticed this behavior on both release version (1.0.2) and master
> branch from github.
>
> Thanks,
> Alin
>
>
> On Fri, Jan 6, 2012 at 7:18 PM, Bryan Fink <[email protected]> wrote:
>
>> On Fri, Jan 6, 2012 at 10:18 AM, Alin Popa <[email protected]> wrote:
>> > and this is the code that I'm using for this:
>> >
>> > -module(simple_mapreduce).
>> >
>> > -compile(export_all).
>> >
>> > main(Pid) ->
>> >   {ok, Pid} = riakc_pb_socket:start_link("127.0.0.1", 8087),
>> >   Fun = fun(Object, _KeyData, none) -> [Object] end,
>> >   riakc_pb_socket:mapred(Pid, {<<"small-bucket">>,[]}, [{map, {qfun,
>> Count},
>> > none, true}]).
>> >
>> >
>> > It's a very simple usage, and according to the documentation, I haven't
>> > missed anything here (I know I can use the modfun instead of qfun for
>> > exactly this functionality, but it's just an example which throws).
>> >
>> > Also, for the master version of riak, I'm getting error as return value
>> of
>> > calling mapred function on riakc_pb_socket:
>> >
>> >
>> {error,<<"{\"phase\":0,\"error\":\"undef\",\"input\":\"{ok,{r_object,<<\\\"small-bucket\\\">>,<<\\\"some-magnific-key-44\\\">>,[{r_cont"...>>}
>> >
>> > Is there a way that I can understand what these logs means ?
>>
>> The clue is the "error:'undef'" field in the error message JSON you
>> received.  Just like any undef error in an erlang program, it's
>> telling you the query tried to call a function that does not exist.
>>
>> The reason the function does not exist is that the Riak cluster does
>> not have access to your 'simple_mapreduce' module.  Since the
>> anonymous function you are submitting was created in that module, Riak
>> needs to be able to load the same version of it in order to evaluate
>> the function.  If you had used modfun instead, you would have received
>> an error complaining that the module was unavailable.
>>
>> To make your module available to Riak, point the 'add_paths' setting
>> in the riak_kv section of your app.config to the directory containing
>> your module's compiled beam file.
>>
>> http://wiki.basho.com/Configuration-Files.html#add_paths
>>
>> Also, be sure to reload the module on each riak cluster node (using
>> 'riak-admin erl_reload' on the command line) after making changes and
>> recompiling your module.
>>
>> Hope that helps,
>> Bryan
>>
>
>
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to