Skip to content
19 changes: 17 additions & 2 deletions R/pkg/R/client.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ determineSparkSubmitBin <- function() {
sparkSubmitBinName
}

# R supports both file separator in the file path (Unix : / and Windows: \) irrespective of the operating system
# but when passing file path to Java or script program, it has to be converted according to operating system

determinefileSeperator <- function() {
if (.Platform$OS.type == "unix") {
fileSeperator <- .Platform$file.sep
} else {
# .Platform$file.sep contains "/" for windows too
# http://www.inside-r.org/r-doc/base/file.path
fileSeperator <- "\\"
}
fileSeperator
}

generateSparkSubmitArgs <- function(args, sparkHome, jars, sparkSubmitOpts, packages) {
if (jars != "") {
jars <- paste("--jars", jars)
Expand All @@ -57,9 +71,10 @@ generateSparkSubmitArgs <- function(args, sparkHome, jars, sparkSubmitOpts, pack
}

launchBackend <- function(args, sparkHome, jars, sparkSubmitOpts, packages) {
sparkSubmitBin <- determineSparkSubmitBin()
sparkSubmitBinName <- determineSparkSubmitBin()
if (sparkHome != "") {
sparkSubmitBin <- file.path(sparkHome, "bin", sparkSubmitBinName)
fileSeperator <- determinefileSeperator()
sparkSubmitBin <- file.path(sparkHome, "bin", sparkSubmitBinName, fsep = fileSeperator)
} else {
sparkSubmitBin <- sparkSubmitBinName
}
Expand Down
2 changes: 1 addition & 1 deletion R/pkg/R/sparkR.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ sparkR.init <- function(
sparkHome = sparkHome,
jars = jars,
sparkSubmitOpts = Sys.getenv("SPARKR_SUBMIT_ARGS", "sparkr-shell"),
sparkPackages = sparkPackages)
packages = sparkPackages )
# wait atmost 100 seconds for JVM to launch
wait <- 0.1
for (i in 1:25) {
Expand Down