|
21 | 21 | #' Download and Install Apache Spark to a Local Directory |
22 | 22 | #' |
23 | 23 | #' \code{install.spark} downloads and installs Spark to a local directory if |
24 | | -#' it is not found. The Spark version we use is the same as the SparkR version. |
25 | | -#' Users can specify a desired Hadoop version, the remote mirror site, and |
26 | | -#' the directory where the package is installed locally. |
| 24 | +#' it is not found. If SPARK_HOME is set in the environment, and that directory is found, that is |
| 25 | +#' returned. The Spark version we use is the same as the SparkR version. Users can specify a desired |
| 26 | +#' Hadoop version, the remote mirror site, and the directory where the package is installed locally. |
27 | 27 | #' |
28 | 28 | #' The full url of remote file is inferred from \code{mirrorUrl} and \code{hadoopVersion}. |
29 | 29 | #' \code{mirrorUrl} specifies the remote path to a Spark folder. It is followed by a subfolder |
|
68 | 68 | #' \href{http://spark.apache.org/downloads.html}{Apache Spark} |
69 | 69 | install.spark <- function(hadoopVersion = "2.7", mirrorUrl = NULL, |
70 | 70 | localDir = NULL, overwrite = FALSE) { |
| 71 | + sparkHome <- Sys.getenv("SPARK_HOME") |
| 72 | + if (isSparkRShell()) { |
| 73 | + stopifnot(nchar(sparkHome) > 0) |
| 74 | + message("Spark is already running in sparkR shell.") |
| 75 | + return(invisible(sparkHome)) |
| 76 | + } else if (!is.na(file.info(sparkHome)$isdir)) { |
| 77 | + message("Spark package found in SPARK_HOME: ", sparkHome) |
| 78 | + return(invisible(sparkHome)) |
| 79 | + } |
| 80 | + |
71 | 81 | version <- paste0("spark-", packageVersion("SparkR")) |
72 | 82 | hadoopVersion <- tolower(hadoopVersion) |
73 | 83 | hadoopVersionName <- hadoopVersionName(hadoopVersion) |
|
0 commit comments