Skip to content

Commit 7beedcc

Browse files
author
Tyson Condie
committed
2 parents 8a2028b + 26b07f1 commit 7beedcc

File tree

67 files changed

+2438
-254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2438
-254
lines changed

R/pkg/NAMESPACE

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ exportMethods("glm",
4444
"spark.gaussianMixture",
4545
"spark.als",
4646
"spark.kstest",
47-
"spark.logit")
47+
"spark.logit",
48+
"spark.randomForest")
4849

4950
# Job group lifecycle management methods
5051
export("setJobGroup",
@@ -350,7 +351,9 @@ export("as.DataFrame",
350351
"uncacheTable",
351352
"print.summary.GeneralizedLinearRegressionModel",
352353
"read.ml",
353-
"print.summary.KSTest")
354+
"print.summary.KSTest",
355+
"print.summary.RandomForestRegressionModel",
356+
"print.summary.RandomForestClassificationModel")
354357

355358
export("structField",
356359
"structField.jobj",
@@ -375,6 +378,8 @@ S3method(print, structField)
375378
S3method(print, structType)
376379
S3method(print, summary.GeneralizedLinearRegressionModel)
377380
S3method(print, summary.KSTest)
381+
S3method(print, summary.RandomForestRegressionModel)
382+
S3method(print, summary.RandomForestClassificationModel)
378383
S3method(structField, character)
379384
S3method(structField, jobj)
380385
S3method(structType, jobj)

R/pkg/R/backend.R

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,27 @@ invokeJava <- function(isStatic, objId, methodName, ...) {
108108
conn <- get(".sparkRCon", .sparkREnv)
109109
writeBin(requestMessage, conn)
110110

111-
# TODO: check the status code to output error information
112111
returnStatus <- readInt(conn)
112+
handleErrors(returnStatus, conn)
113+
114+
# Backend will send +1 as keep alive value to prevent various connection timeouts
115+
# on very long running jobs. See spark.r.heartBeatInterval
116+
while (returnStatus == 1) {
117+
returnStatus <- readInt(conn)
118+
handleErrors(returnStatus, conn)
119+
}
120+
121+
readObject(conn)
122+
}
123+
124+
# Helper function to check for returned errors and print appropriate error message to user
125+
handleErrors <- function(returnStatus, conn) {
113126
if (length(returnStatus) == 0) {
114127
stop("No status is returned. Java SparkR backend might have failed.")
115128
}
116-
if (returnStatus != 0) {
129+
130+
# 0 is success and +1 is reserved for heartbeats. Other negative values indicate errors.
131+
if (returnStatus < 0) {
117132
stop(readString(conn))
118133
}
119-
readObject(conn)
120134
}

R/pkg/R/client.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
# Creates a SparkR client connection object
2121
# if one doesn't already exist
22-
connectBackend <- function(hostname, port, timeout = 6000) {
22+
connectBackend <- function(hostname, port, timeout) {
2323
if (exists(".sparkRcon", envir = .sparkREnv)) {
2424
if (isOpen(.sparkREnv[[".sparkRCon"]])) {
2525
cat("SparkRBackend client connection already exists\n")

R/pkg/R/generics.R

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,9 +1310,11 @@ setGeneric("window", function(x, ...) { standardGeneric("window") })
13101310
#' @export
13111311
setGeneric("year", function(x) { standardGeneric("year") })
13121312

1313-
#' @rdname spark.glm
1313+
###################### Spark.ML Methods ##########################
1314+
1315+
#' @rdname fitted
13141316
#' @export
1315-
setGeneric("spark.glm", function(data, formula, ...) { standardGeneric("spark.glm") })
1317+
setGeneric("fitted")
13161318

13171319
#' @param x,y For \code{glm}: logical values indicating whether the response vector
13181320
#' and model matrix used in the fitting process should be returned as
@@ -1332,13 +1334,38 @@ setGeneric("predict", function(object, ...) { standardGeneric("predict") })
13321334
#' @export
13331335
setGeneric("rbind", signature = "...")
13341336

1337+
#' @rdname spark.als
1338+
#' @export
1339+
setGeneric("spark.als", function(data, ...) { standardGeneric("spark.als") })
1340+
1341+
#' @rdname spark.gaussianMixture
1342+
#' @export
1343+
setGeneric("spark.gaussianMixture",
1344+
function(data, formula, ...) { standardGeneric("spark.gaussianMixture") })
1345+
1346+
#' @rdname spark.glm
1347+
#' @export
1348+
setGeneric("spark.glm", function(data, formula, ...) { standardGeneric("spark.glm") })
1349+
1350+
#' @rdname spark.isoreg
1351+
#' @export
1352+
setGeneric("spark.isoreg", function(data, formula, ...) { standardGeneric("spark.isoreg") })
1353+
13351354
#' @rdname spark.kmeans
13361355
#' @export
13371356
setGeneric("spark.kmeans", function(data, formula, ...) { standardGeneric("spark.kmeans") })
13381357

1339-
#' @rdname fitted
1358+
#' @rdname spark.kstest
13401359
#' @export
1341-
setGeneric("fitted")
1360+
setGeneric("spark.kstest", function(data, ...) { standardGeneric("spark.kstest") })
1361+
1362+
#' @rdname spark.lda
1363+
#' @export
1364+
setGeneric("spark.lda", function(data, ...) { standardGeneric("spark.lda") })
1365+
1366+
#' @rdname spark.logit
1367+
#' @export
1368+
setGeneric("spark.logit", function(data, formula, ...) { standardGeneric("spark.logit") })
13421369

13431370
#' @rdname spark.mlp
13441371
#' @export
@@ -1348,13 +1375,14 @@ setGeneric("spark.mlp", function(data, ...) { standardGeneric("spark.mlp") })
13481375
#' @export
13491376
setGeneric("spark.naiveBayes", function(data, formula, ...) { standardGeneric("spark.naiveBayes") })
13501377

1351-
#' @rdname spark.survreg
1378+
#' @rdname spark.randomForest
13521379
#' @export
1353-
setGeneric("spark.survreg", function(data, formula) { standardGeneric("spark.survreg") })
1380+
setGeneric("spark.randomForest",
1381+
function(data, formula, ...) { standardGeneric("spark.randomForest") })
13541382

1355-
#' @rdname spark.lda
1383+
#' @rdname spark.survreg
13561384
#' @export
1357-
setGeneric("spark.lda", function(data, ...) { standardGeneric("spark.lda") })
1385+
setGeneric("spark.survreg", function(data, formula) { standardGeneric("spark.survreg") })
13581386

13591387
#' @rdname spark.lda
13601388
#' @export
@@ -1364,32 +1392,10 @@ setGeneric("spark.posterior", function(object, newData) { standardGeneric("spark
13641392
#' @export
13651393
setGeneric("spark.perplexity", function(object, data) { standardGeneric("spark.perplexity") })
13661394

1367-
#' @rdname spark.isoreg
1368-
#' @export
1369-
setGeneric("spark.isoreg", function(data, formula, ...) { standardGeneric("spark.isoreg") })
1370-
1371-
#' @rdname spark.gaussianMixture
1372-
#' @export
1373-
setGeneric("spark.gaussianMixture",
1374-
function(data, formula, ...) {
1375-
standardGeneric("spark.gaussianMixture")
1376-
})
1377-
1378-
#' @rdname spark.logit
1379-
#' @export
1380-
setGeneric("spark.logit", function(data, formula, ...) { standardGeneric("spark.logit") })
13811395

13821396
#' @param object a fitted ML model object.
13831397
#' @param path the directory where the model is saved.
13841398
#' @param ... additional argument(s) passed to the method.
13851399
#' @rdname write.ml
13861400
#' @export
13871401
setGeneric("write.ml", function(object, path, ...) { standardGeneric("write.ml") })
1388-
1389-
#' @rdname spark.als
1390-
#' @export
1391-
setGeneric("spark.als", function(data, ...) { standardGeneric("spark.als") })
1392-
1393-
#' @rdname spark.kstest
1394-
#' @export
1395-
setGeneric("spark.kstest", function(data, ...) { standardGeneric("spark.kstest") })

0 commit comments

Comments
 (0)