About second parameter of riakc_pb_socket:mapred

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

About second parameter of riakc_pb_socket:mapred

jason
Hi guys.

To  test mapred_inputs()  in the program, These parameters ([{bucket(), key()} | {bucket(), key(), term()}] | bucket() | {index, bucket(), Index::binary(), key()} | {index,bucket(), Index::binary(), StartKey::key(), EndKey::key()} ) is ok.
The  "Inputs" parameter({modfun, Module::atom(), Function::atom(), [term()]} )   {modfun, riak_search, mapred_search, [ <<"Bucket">>, <<"SearchQuery">>]} is ok.
But myself function is can not work(Inputs = {modfun, trend_riak, test, [<<"a">>, <<"b">>]}). The "trend_riak" module is added riak path.
There are errors in the following:
{error,<<"Error sending inputs: [{<<\"my\">>,<<\"bu\">>}]">>}

The trend_riak module code.
  1 -module(trend_riak).
  2 
  3 -export([test/3]).
 4  [{<<"my">>, <<"bu">>}].             

Where is wrong? 

Best wish ,thank you.
Jason

mapred_inputs()

mapred_inputs() = [{bucket()key()} | {bucket()key(), term()}] | {modfun, Module::atom(), Function::atom(), [term()]} | bucket() | {index, bucket(), Index::binary(), key()} | {index,bucket(), Index::binary(), StartKey::key(), EndKey::key()}

mapred/3

mapred(Pid::pid(), Inputs::mapred_inputs(), Query::[mapred_queryterm()]) -> {ok, mapred_result()} | {error, {badqterm, mapred_queryterm()}} | {error, timeout} | {error, term()}

Equivalent to mapred(Inputs, Query, default_timeout(mapred)).


--
只为成功找方法,不为失败找理由

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: About second parameter of riakc_pb_socket:mapred

jason
Who can answer me?  thanks.

2012/7/13 郎咸武 <[hidden email]>
Hi guys.

To  test mapred_inputs()  in the program, These parameters ([{bucket(), key()} | {bucket(), key(), term()}] | bucket() | {index, bucket(), Index::binary(), key()} | {index,bucket(), Index::binary(), StartKey::key(), EndKey::key()} ) is ok.
The  "Inputs" parameter({modfun, Module::atom(), Function::atom(), [term()]} )   {modfun, riak_search, mapred_search, [ <<"Bucket">>, <<"SearchQuery">>]} is ok.
But myself function is can not work(Inputs = {modfun, trend_riak, test, [<<"a">>, <<"b">>]}). The "trend_riak" module is added riak path.
There are errors in the following:
{error,<<"Error sending inputs: [{<<\"my\">>,<<\"bu\">>}]">>}

The trend_riak module code.
  1 -module(trend_riak).
  2 
  3 -export([test/3]).
 4  [{<<"my">>, <<"bu">>}].             

Where is wrong? 

Best wish ,thank you.
Jason

mapred_inputs()

mapred_inputs() = [{bucket()key()} | {bucket()key(), term()}] | {modfun, Module::atom(), Function::atom(), [term()]} | bucket() | {index, bucket(), Index::binary(), key()} | {index,bucket(), Index::binary(), StartKey::key(), EndKey::key()}

mapred/3

mapred(Pid::pid(), Inputs::mapred_inputs(), Query::[mapred_queryterm()]) -> {ok, mapred_result()} | {error, {badqterm, mapred_queryterm()}} | {error, timeout} | {error, term()}

Equivalent to mapred(Inputs, Query, default_timeout(mapred)).


--
只为成功找方法,不为失败找理由



--
只为成功找方法,不为失败找理由

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: About second parameter of riakc_pb_socket:mapred

bryan-basho
Administrator
In reply to this post by jason
On Thu, Jul 12, 2012 at 11:10 PM, 郎咸武 <[hidden email]> wrote:

> But myself function is can not work(Inputs = {modfun, trend_riak, test,
> [<<"a">>, <<"b">>]}). The "trend_riak" module is added riak path.
> There are errors in the following:
> {error,<<"Error sending inputs: [{<<\"my\">>,<<\"bu\">>}]">>}
>
> The trend_riak module code.
>   1 -module(trend_riak).
>   2
>   3 -export([test/3]).
>  4  [{<<"my">>, <<"bu">>}].
>
> Where is wrong?

Hi, Jason. The "modfun" input type is not widely used outside of Riak,
so its documentation has not spread to most client libraries. A
description of it is available in riak_kv:

https://github.com/basho/riak_kv/blob/master/src/riak_kv_mrc_pipe.erl#L39-60

A module implementing that interface looks like this:

    -module(trend_riak).

    -export([test/3]).

    test(Pipe, _Arg, _Timeout) ->
        Inputs = [{<<"my">>, <<"bu">>}],
        [ ok = riak_pipe:queue_work(Pipe, Input) || Input <- Inputs ],
        riak_pipe:eoi(Pipe).

And an example usage is:

    riakc_pb_socket:mapred(S,
                           {modfun, trend_riak, test, whatever},
                           [{map, {modfun, riak_kv_mapreduce,
map_object_value}, none, true}]).

Hope that helps,
Bryan

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com