From 1c9b83083edc4b72da8d1b86fd28ea48d66a1a8a Mon Sep 17 00:00:00 2001 From: Kopilov Aleksandr Date: Fri, 27 Aug 2021 15:40:55 +0300 Subject: [PATCH] RCaller-4.0.2 Disable Arrow compression explicitly, cosmetic fixes and upgrades --- RCaller/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- RCaller/pom.xml | 4 ++-- .../benchmark/PassingArraysAndMatrices.java | 2 +- .../com/github/rcaller/rstuff/RCaller.java | 3 --- .../java/com/github/rcaller/rstuff/RCode.java | 2 +- .../java/com/github/rcaller/util/Globals.java | 6 +++--- RCaller/src/main/resources/arrow_bridge.R | 10 +++++----- README.md | 20 +++++++++++-------- 9 files changed, 26 insertions(+), 25 deletions(-) diff --git a/RCaller/build.gradle b/RCaller/build.gradle index 115af9d..a8491ba 100644 --- a/RCaller/build.gradle +++ b/RCaller/build.gradle @@ -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 { diff --git a/RCaller/gradle/wrapper/gradle-wrapper.properties b/RCaller/gradle/wrapper/gradle-wrapper.properties index 0f80bbf..ffed3a2 100644 --- a/RCaller/gradle/wrapper/gradle-wrapper.properties +++ b/RCaller/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/RCaller/pom.xml b/RCaller/pom.xml index 2d2169b..55450b9 100644 --- a/RCaller/pom.xml +++ b/RCaller/pom.xml @@ -3,7 +3,7 @@ com.github.jbytecode RCaller - 4.0.1 + 4.0.2 jar RCaller @@ -23,7 +23,7 @@ curcean.paul@gmail.com - Kopilov Alexander + Kopilov Aleksandr kopilov.ad@gmail.com diff --git a/RCaller/src/main/java/benchmark/PassingArraysAndMatrices.java b/RCaller/src/main/java/benchmark/PassingArraysAndMatrices.java index 97201ab..d6b93f9 100644 --- a/RCaller/src/main/java/benchmark/PassingArraysAndMatrices.java +++ b/RCaller/src/main/java/benchmark/PassingArraysAndMatrices.java @@ -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); } diff --git a/RCaller/src/main/java/com/github/rcaller/rstuff/RCaller.java b/RCaller/src/main/java/com/github/rcaller/rstuff/RCaller.java index 5a4d310..f394ff2 100644 --- a/RCaller/src/main/java/com/github/rcaller/rstuff/RCaller.java +++ b/RCaller/src/main/java/com/github/rcaller/rstuff/RCaller.java @@ -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; diff --git a/RCaller/src/main/java/com/github/rcaller/rstuff/RCode.java b/RCaller/src/main/java/com/github/rcaller/rstuff/RCode.java index b81a910..76a915f 100644 --- a/RCaller/src/main/java/com/github/rcaller/rstuff/RCode.java +++ b/RCaller/src/main/java/com/github/rcaller/rstuff/RCode.java @@ -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) { diff --git a/RCaller/src/main/java/com/github/rcaller/util/Globals.java b/RCaller/src/main/java/com/github/rcaller/util/Globals.java index 24050af..3f1e543 100644 --- a/RCaller/src/main/java/com/github/rcaller/util/Globals.java +++ b/RCaller/src/main/java/com/github/rcaller/util/Globals.java @@ -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 - mhsatman@yahoo.com"; public final static String license = "LGPL v3.0"; diff --git a/RCaller/src/main/resources/arrow_bridge.R b/RCaller/src/main/resources/arrow_bridge.R index 7d5fc0f..7390378 100644 --- a/RCaller/src/main/resources/arrow_bridge.R +++ b/RCaller/src/main/resources/arrow_bridge.R @@ -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,7 +67,7 @@ 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 @@ -75,7 +75,7 @@ send_element_by_arrow <- function(obj, name, stream) { 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") diff --git a/README.md b/README.md index d47c945..99640fc 100644 --- a/README.md +++ b/README.md @@ -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: com.github.jbytecode RCaller - 4.0.1 - jar-with-dependencies + 4.0.2 ```