-1

I saw the examples for Riak erlang and JS mapreduce. But I am a JAVA guy :), like to do it in JAVA. Moreover JS mapreduce is deprecated.

  1. Is there a way to do it in Java? Kindly give a sample.
  2. I was also looking for a Java sample of Riak 2.0 Search.

In Riak docs steps looks huge for riak-search. This might look like a small cookbook for mapreduce and search. Can it be summarized with actually steps with an example.

ISSUE

I tried the steps in github following is what i see :

   ./rebar get-deps
==> meck (get-deps)
==> protobuffs (get-deps)
==> hamcrest (get-deps)
==> riak_pb (get-deps)
==> riak-erlang-client (get-deps)
./rebar compile
==> meck (pre_compile)
==> meck (compile)
==> protobuffs (pre_compile)
==> protobuffs (compile)
==> hamcrest (pre_compile)
==> hamcrest (compile)
==> hamcrest (post_compile)
==> riak_pb (pre_compile)
==> riak_pb (compile)
==> riak-erlang-client (compile)
raghuveer@ubuntu:~/erlang-git/riak-erlang-client$ erl -pa $PATH_TO_RIAKC/ebin $PATH_TO_RIAKC/deps/*/ebin
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]

Eshell V7.3  (abort with ^G)
1> code:which(riakc_pb_socket).
non_existing
Raghuveer
  • 2,859
  • 7
  • 34
  • 66
  • eacces is a posix error. Seems that there is a file system permission needed. Noting that the error occurred in rebar_deps:download_source, it would seem that the user account running the build either doesn't have permission to access the source files, or doesn't have write permission to create or write to the deps directory. – Joe Nov 16 '16 at 06:30
  • I used a root users only, `sudo apt-get install *` that should have fixed it isn't it ? – Raghuveer Nov 16 '16 at 07:54
  • 1
    It looks like the develop branch in that client repository is failing build. Try building from the master branch. – Joe Nov 17 '16 at 19:41
  • I tried the master, now the make went fine but code:which(riakc_pb_socket). still says non-existing. how to also uninstall erlang-riak-client. Updated the steps above. – Raghuveer Nov 21 '16 at 04:54

1 Answers1

2

The map and reduce phase code must be either erlang or javascript. You can use java on the client side, but the mapreduce code needs to be executed in the Riak node, which uses erlang natively and has spidermonkey to run javascript.

There are some pre-defined functions that might get you started at https://github.com/basho/riak_kv/blob/develop/src/riak_kv_mapreduce.erl

The documentation contains examples of using java with search: https://docs.basho.com/riak/kv/2.1.4/developing/usage/search/

Joe
  • 25,000
  • 3
  • 22
  • 44
  • have you looked at http://stackoverflow.com/questions/11543447/getting-mapreduce-results-on-riak-using-the-java-client ? – Joe Nov 15 '16 at 04:07
  • You might also check out the mapreduce links to the javadoc at the bottom of https://github.com/basho/riak-java-client – Joe Nov 15 '16 at 04:16
  • I know these links but i need some step by step summary to follow. I dont have understanding about erlang also. The link you mentioned is for JS and java docs link doesnt have any examples. Is there any fast tutorials other than the official site. Also when i ran from https://docs.basho.com/riak/kv/2.1.4/developing/usage/mapreduce/ "{ok, Riak} = riakc_pb_socket:start_link("127.0.0.1", 8087)." i see the error "exception error: undefined function riakc_pb_socket:start_link/2" – Raghuveer Nov 15 '16 at 04:48
  • 1
    That error means the `riakc_pb_socket` module is not in your code path. There is a pretty good getting started at https://github.com/basho/riak-erlang-client – Joe Nov 15 '16 at 05:22
  • Updated the issue am currently facing in my post above. When i call `make` i see that error – Raghuveer Nov 16 '16 at 04:34