-
Notifications
You must be signed in to change notification settings - Fork 324
/
Copy pathsparkR
executable file
·39 lines (31 loc) · 893 Bytes
/
sparkR
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
FWDIR="$(cd `dirname $0`; pwd)"
export PROJECT_HOME="$FWDIR"
unset JAVA_HOME
export R_PROFILE_USER="/tmp/sparkR.profile"
if [ $# -gt 0 ]; then
# If we are running an R program, only set libPaths and use Rscript
cat > /tmp/sparkR.profile << EOF
.First <- function() {
projecHome <- Sys.getenv("PROJECT_HOME")
.libPaths(c(paste(projecHome,"/lib", sep=""), .libPaths()))
Sys.setenv(NOAWT=1)
}
EOF
Rscript "$@"
else
# If we don't have an R file to run, initialize context and run R
cat > /tmp/sparkR.profile << EOF
.First <- function() {
projecHome <- Sys.getenv("PROJECT_HOME")
Sys.setenv(NOAWT=1)
.libPaths(c(paste(projecHome,"/lib", sep=""), .libPaths()))
library(SparkR)
sc <- sparkR.init(Sys.getenv("MASTER", unset = ""))
assign("sc", sc, envir=.GlobalEnv)
cat("\n Welcome to SparkR!")
cat("\n Spark context is available as sc\n")
}
EOF
R
fi