Skip to content

Commit

Permalink
RCaller-4.0.2 Disable Arrow compression explicitly, cosmetic fixes an…
Browse files Browse the repository at this point in the history
…d upgrades
Kopilov committed Aug 27, 2021
1 parent f0aedf7 commit 1c9b830
Showing 9 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion RCaller/build.gradle
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ repositories {
}

group = 'com.github.jbytecode'
version = '4.0.1'
version = '4.0.2'
description = 'RCaller is a software library which simplifies performing data analysis and statistical calculations in Java using R. The details are hidden from users including transferring data between platforms, function calls, and retrieving results.'

dependencies {
2 changes: 1 addition & 1 deletion RCaller/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions RCaller/pom.xml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

<groupId>com.github.jbytecode</groupId>
<artifactId>RCaller</artifactId>
<version>4.0.1</version>
<version>4.0.2</version>
<packaging>jar</packaging>

<name>RCaller</name>
@@ -23,7 +23,7 @@
<email>[email protected]</email>
</developer>
<developer>
<name>Kopilov Alexander</name>
<name>Kopilov Aleksandr</name>
<email>[email protected]</email>
</developer>
</developers>
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ private final static double[][] generateRandomMatrix(int n, int m) {

public static void main(String[] args) {

performSimulation(/* size of vector */ 2, 100 /* times */ , SimType.Vector);
performSimulation(/* size of vector */ 20000, 100 /* times */ , SimType.Vector);

}

3 changes: 0 additions & 3 deletions RCaller/src/main/java/com/github/rcaller/rstuff/RCaller.java
Original file line number Diff line number Diff line change
@@ -34,9 +34,6 @@
import com.github.rcaller.util.Globals;

import java.io.*;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
2 changes: 1 addition & 1 deletion RCaller/src/main/java/com/github/rcaller/rstuff/RCode.java
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ public final void clear() {
* @param var name of variable to be exported
*/
public void appendStandardCodeToAppend(File outputFile, String var) {
addRCode(RCodeIO.getVariableExporting(rCallerOptions, var, outputFile.toPath().toUri()));
addRCode(RCodeIO.getVariableExporting(rCallerOptions, var, outputFile.toURI()));
}

static String createEndSignalCode(File outputFile) {
6 changes: 3 additions & 3 deletions RCaller/src/main/java/com/github/rcaller/util/Globals.java
Original file line number Diff line number Diff line change
@@ -39,12 +39,12 @@
public class Globals {

public static String cranRepos = "http://cran.r-project.org";
public static String RScript_Windows = "C:\\Program Files\\R\\R-3.6.3\\bin\\Rscript.exe";
public static String RScript_Windows = "C:\\Program Files\\R\\R-4.1.1\\bin\\Rscript.exe";
public static String RScript_Linux = "/usr/bin/Rscript";
public static String RScript_Mac = "/usr/local/bin/Rscript";
public static String Rscript_current;

public static String R_Windows = "C:\\Program Files\\R\\R-3.6.3\\bin\\R.exe";
public static String R_Windows = "C:\\Program Files\\R\\R-4.1.1\\bin\\R.exe";
public static String R_Linux = "/usr/bin/R";
public static String R_Mac = "/usr/local/bin/R";
public static String R_current;
@@ -63,7 +63,7 @@ public class Globals {

public static GraphicsTheme theme = new DefaultTheme();

public final static String version = "RCaller 4.0.0";
public final static String version = "RCaller 4.0.2";
public final static String about = "Author: Mehmet Hakan Satman - [email protected]";
public final static String license = "LGPL v3.0";

10 changes: 5 additions & 5 deletions RCaller/src/main/resources/arrow_bridge.R
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ require("arrow")
send_element_by_arrow <- function(obj, name, stream) {
if (is.data.frame(obj)) {
#Export by Arrow as is
arrow::write_ipc_stream(obj, stream)
arrow::write_ipc_stream(obj, stream, compression = "uncompressed")
return()
}
if (is.array(obj)) {
@@ -22,7 +22,7 @@ send_element_by_arrow <- function(obj, name, stream) {
schema_fixed_size <- schema(matrix_column=fixed_size_list_of(type = batch_typedetect$schema$fields[[1]]$type$value_type, columns))
batch <- record_batch(matrix_column=matrix_jagged_fixedsize, schema=schema_fixed_size)
names(batch) <- name
arrow::write_ipc_stream(batch, stream)
arrow::write_ipc_stream(batch, stream, compression = "uncompressed")
return()
}
if (length(dim(obj)) > 2) {
@@ -39,7 +39,7 @@ send_element_by_arrow <- function(obj, name, stream) {
#Union typed and nested lists might not work
batch <- record_batch(list_column=obj)
names(batch) <- name
arrow::write_ipc_stream(batch, stream)
arrow::write_ipc_stream(batch, stream, compression = "uncompressed")
return()
} else if (length(names(obj)) > 0) {
#Export each field separatly
@@ -67,15 +67,15 @@ send_element_by_arrow <- function(obj, name, stream) {
#export filled vector with auto type detect
batch <- record_batch(vector_column=obj)
names(batch) <- name
arrow::write_ipc_stream(batch, stream)
arrow::write_ipc_stream(batch, stream, compression = "uncompressed")
return()
} else if (length(obj) == 0) {
#export empty element
obj <- c(1)
type_example_batch <- record_batch(empty_column=obj)
length(obj) <- 0
empty_batch <- record_batch(empty_column=obj, schema=type_example_batch$schema)
arrow::write_ipc_stream(empty_batch, stream)
arrow::write_ipc_stream(empty_batch, stream, compression = "uncompressed")
return()
# } else {
# stop("Probably unsupported output")
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -34,14 +34,17 @@ RCaller is a production ready library for calling R functions from within Java.
Java software that needs enhanced statistical calculations, RCaller is a practical solution to integrate
these languages. R has many well-tested and matured packages for automatic time series model selection,
clustering, segmentation and classification, non-linear and robust regression estimations, data and text
mining, linear and non-linear programming, generating plots, function optimization besides other research tools. RCaller brings all of the functionality that R serves in Java. Easy installation and integration steps and steep learning curve make RCaller a suitable solution. RCaller's computation overhead is generating XML files in R side and parsing XML to Java objects in Java side.
mining, linear and non-linear programming, generating plots, function optimization besides other research tools.
RCaller brings all of the functionality that R serves in Java. Easy installation and integration steps and steep learning curve make RCaller a suitable solution.
RCaller's computation overhead is generating XML files in R side and parsing XML to Java objects in Java side.


# Dependencies
RCaller compiled jar library requires JRE (v1.8 or higher) and R installed in the runtime environment. If you want to compile from source, JDK (v.1.8 or higher) and maven are also required
for building process. Maven is responsible for downloading and install additional Java dependencies
RCaller compiled jar library requires JRE (v11 or higher) and R installed in the runtime environment.
If you want to compile from source, JDK (v.11 or higher) and Maven (or Gradle) are also required
for building process. Maven is responsible for downloading and install additional Java dependencies
defined in [pom file](https://github.com/jbytecode/rcaller/blob/master/RCaller/pom.xml). RCaller
does not use any version specific property of R.
does not use any version specific property of R.


# Usage
@@ -79,14 +82,16 @@ It is recommended to take a look at the existing [tests](https://github.com/jbyt

RCaller uses XML for reading R output by default. This is lightweight but not very fast way.
For speeding up the IO, install R [arrow](https://cran.r-project.org/web/packages/arrow/index.html)
package and add dependencies `org.apache.arrow:arrow-vector` and `org.apache.arrow:arrow-memory-netty` to your Java project.
package and add dependencies
[org.apache.arrow:arrow-vector](https://search.maven.org/artifact/org.apache.arrow/arrow-vector/5.0.0/jar) and
[org.apache.arrow:arrow-memory-netty](https://search.maven.org/artifact/org.apache.arrow/arrow-memory-netty/5.0.0/jar) to your Java project.
RCaller will use Arrow format automatically if it is available both in R and Java.

Errors handling can impact performance in online mode and is disabled by default.
Use `RCaller.runAndReturnResultOnline(String var, boolean addTryCatch)` method with `addTryCatch = true` for throwing R exceptions to Java.

# API Docs
[Here is the auto-generated Javadocs](https://github.com/jbytecode/rcaller/releases/download/RCaller-4.0.1/RCaller-4.0.1-javadoc.jar).
[Here is the auto-generated Javadocs](https://github.com/jbytecode/rcaller/releases/download/RCaller-4.0.2/RCaller-4.0.2-javadoc.jar).

# Building and Installing RCaller
There are many options to integrate RCaller with a Java Project. First option is to download pre-compiled jar file and add it to the classpath or pom.xml. [pre-compiled jar files](https://github.com/jbytecode/rcaller/releases) are here.
@@ -105,8 +110,7 @@ The last option is to use maven dependency:
<dependency>
<groupId>com.github.jbytecode</groupId>
<artifactId>RCaller</artifactId>
<version>4.0.1</version>
<classifier>jar-with-dependencies</classifier>
<version>4.0.2</version>
</dependency>
```

0 comments on commit 1c9b830

Please sign in to comment.