Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling Java functions from R using RProtoBuf (Protocol Buffers)

It is not entirely obvious how to go about using RProtoBuf for communicating between R and other languages (Java, in my case).

The RprotoBuf Developers developed something that is still here - https://r-forge.r-project.org/scm/viewvc.php/java/?root=rprotobuf, but it seems very outdated. I am not sure if this is the way to go. Here are two conversations between the authors of RProtoBuf that might help with understanding the code -

http://lists.r-forge.r-project.org/pipermail/rprotobuf-yada/2009-December/000116.html

http://lists.r-forge.r-project.org/pipermail/rprotobuf-yada/2009-December/000119.html

It seems that they started work with Java and then abandoned it in C++'s favour!

Is there anyone using R-RProtoBuf-Java combination? How do you do it? Is there a tutorial or example available?

My exposure to Java is very very limited. I want to use a few programs written in Java.

Edit : To clarify, I suppose I want to see an example of an R rpc client being used with RProtobuf. Pointers towards Java RPC servers would be welcome.

Edit2 : The first link actually points to some documentation generator code, as Dirk pointed out.

like image 426
Soumendra Avatar asked Nov 04 '22 16:11

Soumendra


2 Answers

I don't know about RProtoBuf, but if you just want to call Java from R, then you might be interested in rJava.

It is not outdated and has examples (right on the main page, see the link).

like image 169
Dario Seidl Avatar answered Nov 09 '22 03:11

Dario Seidl


We have recently published a preprint on arXiv of a JSS paper we wrote with more examples of using RProtoBuf, including sending RPC requests to remote web services. For more exposition of sharing data between R and other languages with RProtoBuf, see RProtoBuf: Efficient Cross-Language Data Serialization in R.

You can use RProtoBuf with any transport mechanism, as explained in the article -- You can save serialized protocol buffers to files to be read by other applications written in other languages, or you can send them over connections/sockets or other higher level RPC systems. Protocol Buffers are widely used in everything from Sony Playstations to large scale web services, but they do not include an RPC system -- you use them as your serialization format with whatever transport system you are already using.

like image 37
MurrayStokely Avatar answered Nov 09 '22 02:11

MurrayStokely