Skip to content

Commit

Permalink
add data_max_factor_levels to h2o.init() in R
Browse files Browse the repository at this point in the history
  • Loading branch information
spennihana committed Jan 13, 2015
1 parent f0f9635 commit f7a7def
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
19 changes: 14 additions & 5 deletions R/h2o-package/R/Wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 3) If user does want to start H2O, but running non-locally, print an error
h2o.init <- function(ip = "127.0.0.1", port = 54321, startH2O = TRUE, forceDL = FALSE, Xmx,
beta = FALSE, assertion = TRUE, license = NULL, nthreads = -2, max_mem_size = NULL, min_mem_size = NULL,
ice_root = NULL, strict_version_check = TRUE) {
ice_root = NULL, strict_version_check = TRUE, data_max_factor_levels = 65000) {
if(!is.character(ip)) stop("ip must be of class character")
if(!is.numeric(port)) stop("port must be of class numeric")
if(!is.logical(startH2O)) stop("startH2O must be of class logical")
Expand All @@ -21,6 +21,7 @@ h2o.init <- function(ip = "127.0.0.1", port = 54321, startH2O = TRUE, forceDL =
if(!is.null(license) && !is.character(license)) stop("license must be of class character")
if(!is.null(ice_root) && !is.character(ice_root)) stop("ice_root must be of class character")
if(!is.logical(strict_version_check)) stop("strict_version_check must be of class logical")
if(!is.numeric(data_max_factor_levels)) stop("`data_max_factor_levels` must be numeric.")

if ((R.Version()$major == "3") && (R.Version()$minor == "1.0")) {
warning("H2O is specifically not compatible with this exact")
Expand All @@ -44,8 +45,8 @@ h2o.init <- function(ip = "127.0.0.1", port = 54321, startH2O = TRUE, forceDL =
# Disable Up.json for now, since it doesn't exist in most builds.
# Re-enable this sometime a few months from now.
# myUpURL = paste("http://", ip, ":", port, "/Up.json", sep="")
myUpURL = paste("http://", ip, ":", port, sep="")
myURL = paste("http://", ip, ":", port, sep="")
myUpURL <- paste("http://", ip, ":", port, sep="")
myURL <- paste("http://", ip, ":", port, sep="")
warnNthreads = FALSE
if(!url.exists(myUpURL, .opts = curlOptions(useragent=R.version.string))) {
if(!startH2O)
Expand All @@ -58,7 +59,11 @@ h2o.init <- function(ip = "127.0.0.1", port = 54321, startH2O = TRUE, forceDL =
nthreads = 2
}

.h2o.startJar(nthreads = nthreads, max_memory = max_mem_size, min_memory = min_mem_size, beta = beta, assertion = assertion, forceDL = forceDL, license = license, ice_root = ice_root)
.h2o.startJar(nthreads = nthreads, max_memory = max_mem_size,
min_memory = min_mem_size, beta = beta,
assertion = assertion, forceDL = forceDL,
license = license, ice_root = ice_root,
max_factor_levels = data_max_factor_levels)

count = 0;
while(!url.exists(myURL) && (count < 60)) {
Expand Down Expand Up @@ -251,7 +256,10 @@ h2o.clusterStatus <- function(client) {
# h2o.shutdown(new("H2OClient", ip=ip, port=port), prompt = FALSE)
# }

.h2o.startJar <- function(nthreads = -1, max_memory = NULL, min_memory = NULL, beta = FALSE, assertion = TRUE, forceDL = FALSE, license = NULL, ice_root) {
.h2o.startJar <- function(nthreads = -1, max_memory = NULL,
min_memory = NULL, beta = FALSE,
assertion = TRUE, forceDL = FALSE,
license = NULL, ice_root, max_factor_levels = 65000) {
command <- .h2o.checkJava()

if (! is.null(license)) {
Expand Down Expand Up @@ -313,6 +321,7 @@ http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.h
if(nthreads > 0) args <- c(args, "-nthreads", nthreads)
if(beta) args <- c(args, "-beta")
if(!is.null(license)) args <- c(args, "-license", license)
args <- c(args, "-data_max_factor_levels", max_factor_levels)

cat("\n")
cat( "Note: In case of errors look at the following log files:\n")
Expand Down
3 changes: 2 additions & 1 deletion R/h2o-package/man/h2o.init.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Connects to a running H2O instance and checks the local H2O R package is the cor
h2o.init(ip = "127.0.0.1", port = 54321, startH2O = TRUE, forceDL = FALSE, Xmx,
beta = FALSE, assertion = TRUE, license = NULL,
nthreads = -2, max_mem_size, min_mem_size,
ice_root = NULL, strict_version_check = TRUE)}
ice_root = NULL, strict_version_check = TRUE, data_max_factor_levels = 65000)}

\arguments{
\item{ip}{Object of class \code{"character"} representing the IP address of the server where H2O is running.}
Expand All @@ -23,6 +23,7 @@ h2o.init(ip = "127.0.0.1", port = 54321, startH2O = TRUE, forceDL = FALSE, Xmx,
\item{min_mem_size}{(Optional) A string specifying the minimum size, in bytes, of the memory allocation pool to H2O. This value must a multiple of 1024 greater than 2MB. Append the letter m or M to indicate megabytes, or g or G to indicate gigabytes. This value is only used when R starts H2O. }
\item{ice_root}{(Optional) A directory specifying where H2O should write log files and spill to disk (if needed). Default is tempdir(). This value is only used when R starts H2O.}
\item{strict_version_check}{(Optional) Setting this to FALSE is unsupported and should only be done when advised by technical support.}
\item{data_max_factor_levels}{(Optional) The limit for the number of factor levels that may appear in a single column. Default is 65,000.}
}
\details{
This method first checks if H2O is connectible. If it cannot connect and \code{startH2O = TRUE} with IP of localhost, it will attempt to start an instance of H2O with IP = localhost, port = 54321. Otherwise, it stops immediately with an error.
Expand Down

0 comments on commit f7a7def

Please sign in to comment.