Using the Local Client from a riak-attach session

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using the Local Client from a riak-attach session

Derek Sanderson
Digging deeper into Erlang Map Reduces, I'm trying to test one out via the local client, but I cannot find an example of providing a 2i along with the bucket (instead of bucket alone, or bucket + key list) when I run things from the local riak client in the erlang vm when you attach to a running node.

Does anyone have an example of how to accomplish this? I assume it's something simple, but I cannot find any examples of this.

Thanks in advance for the help

_______________________________________________
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
|  
Report Content as Inappropriate

Re: Using the Local Client from a riak-attach session

Daniil Churikov
    {ok, C} = riak:local_client(),                                                                                                                            
    {ok, Keys} = C:get_index(                                                                                                                          
        <<"bucket_name">>, {eq, <<"key_name_bin">>, KeyVal}                                                                                                        
    ),                                                                                                                                                        
                                                                                                                                                               
    {ok, Data} = C:mapred(                                                                                                                            
        [{<<"bucket_name">>, K} || K <- Keys],                                                                                                          
        [riak_kv_mapreduce:map_identity(true)]                                                                                                                
    ).
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using the Local Client from a riak-attach session

Daniil Churikov
Another option, if you want range query:

    {ok, C} = riak:local_client(),
    {ok, Keys} = C:get_index(<<"bucket_name">>, {range, <<"key_name_bin">>, KeyStart, KeyTo}),
    ...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using the Local Client from a riak-attach session

Derek Sanderson
I love this mailing list

Thank you Daniil! I had almost exactly the first thing you recommended, but the example I found had a slightly different notation, and was throwing errors that I couldn't figure out.

Your example seems to be working, and I think I can get past my issue

Thanks again

On Thu, Jan 17, 2013 at 10:30 PM, Daniil Churikov <[hidden email]> wrote:
Another option, if you want range query:

    {ok, C} = riak:local_client(),
    {ok, Keys} = C:get_index(<<"bucket_name">>, {range, <<"key_name_bin">>,
KeyStart, KeyTo}),
    ...



--
View this message in context: http://riak-users.197444.n3.nabble.com/Using-the-Local-Client-from-a-riak-attach-session-tp4026572p4026578.html
Sent from the Riak Users mailing list archive at Nabble.com.

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


_______________________________________________
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
|  
Report Content as Inappropriate

Re: Using the Local Client from a riak-attach session

Evan Vigil-McClanahan
Note that this uses the luke mapreduce subsystem, which isn't a good
idea as it's been deprecated going forward.

Unfortunately there doesn't seem to be a way that's as simple to do
pipe mapreduce jobs.  I'll ping people and see if we can't get you all
some code that's slightly easier to use.

On Fri, Jan 18, 2013 at 5:09 AM, Derek Sanderson <[hidden email]> wrote:

> I love this mailing list
>
> Thank you Daniil! I had almost exactly the first thing you recommended, but
> the example I found had a slightly different notation, and was throwing
> errors that I couldn't figure out.
>
> Your example seems to be working, and I think I can get past my issue
>
> Thanks again
>
>
> On Thu, Jan 17, 2013 at 10:30 PM, Daniil Churikov <[hidden email]> wrote:
>>
>> Another option, if you want range query:
>>
>>     {ok, C} = riak:local_client(),
>>     {ok, Keys} = C:get_index(<<"bucket_name">>, {range,
>> <<"key_name_bin">>,
>> KeyStart, KeyTo}),
>>     ...
>>
>>
>>
>> --
>> View this message in context:
>> http://riak-users.197444.n3.nabble.com/Using-the-Local-Client-from-a-riak-attach-session-tp4026572p4026578.html
>> Sent from the Riak Users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> riak-users mailing list
>> [hidden email]
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>
>
> _______________________________________________
> riak-users mailing list
> [hidden email]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>

_______________________________________________
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
|  
Report Content as Inappropriate

Re: Using the Local Client from a riak-attach session

Christian Dahlqvist
Hi Derek,

The Riak Erlang client (https://github.com/basho/riak-erlang-client) has good support for mapreduce, so it may be worthwhile switching to this. 

Here is an example of how to count records returned by a 2i lookup using a map reduce query:

riakc_pb_socket:mapred(Pid, {index, <<"bucket">>, <<"index_int">>, <<"1">>, <<"50">>},
                            [{reduce, {modfun, 'riak_kv_mapreduce', 'reduce_count_inputs'}, none, true}]).

Hope this helps.

Best regards,

Christian

--------------------
Christian Dahlqvist
Client Services Engineer
Basho Technologies
EMEA Office
E-mail: [hidden email]
Skype: c.dahlqvist
Mobile: +44 7890 590 910

On 18 Jan 2013, at 09:48, Evan Vigil-McClanahan <[hidden email]> wrote:

Note that this uses the luke mapreduce subsystem, which isn't a good
idea as it's been deprecated going forward.

Unfortunately there doesn't seem to be a way that's as simple to do
pipe mapreduce jobs.  I'll ping people and see if we can't get you all
some code that's slightly easier to use.

On Fri, Jan 18, 2013 at 5:09 AM, Derek Sanderson <[hidden email]> wrote:
I love this mailing list

Thank you Daniil! I had almost exactly the first thing you recommended, but
the example I found had a slightly different notation, and was throwing
errors that I couldn't figure out.

Your example seems to be working, and I think I can get past my issue

Thanks again


On Thu, Jan 17, 2013 at 10:30 PM, Daniil Churikov <[hidden email]> wrote:

Another option, if you want range query:

   {ok, C} = riak:local_client(),
   {ok, Keys} = C:get_index(<<"bucket_name">>, {range,
<<"key_name_bin">>,
KeyStart, KeyTo}),
   ...



--
View this message in context:
http://riak-users.197444.n3.nabble.com/Using-the-Local-Client-from-a-riak-attach-session-tp4026572p4026578.html
Sent from the Riak Users mailing list archive at Nabble.com.

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



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


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


_______________________________________________
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
|  
Report Content as Inappropriate

Re: Using the Local Client from a riak-attach session

Daniil Churikov
But if I need to call 2i query from inside of another mapreduce job (from erlang module), how could I use riakc_pb_socket?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using the Local Client from a riak-attach session

bryan-basho
Administrator
In reply to this post by Evan Vigil-McClanahan
On Fri, Jan 18, 2013 at 11:48 AM, Evan Vigil-McClanahan
<[hidden email]> wrote:
> Note that this uses the luke mapreduce subsystem, which isn't a good
> idea as it's been deprecated going forward.
>
> Unfortunately there doesn't seem to be a way that's as simple to do
> pipe mapreduce jobs.  I'll ping people and see if we can't get you all
> some code that's slightly easier to use.

Pipe-based mapreduce is encapsulated in the `riak_kv_mrc_pipe` module.
Instead of `C:mapred...`, use `riak_kv_mrc_pipe:mapred...`. Note that
the next release of riak drops the `riak_client`, luke-based version,
and only the pipe-based version remains.

-Bryan

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