Skip to content

Commit

Permalink
Add h2o.setMaxLastValue().
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkraljevic committed Mar 19, 2015
1 parent 67e7da9 commit c4f64c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/h2o-package/R/Classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ as.h2o <- function(client, object, key = "", header, sep = "") {
if(!is.character(key)) stop("key must be of class character")
if(missing(key) || nchar(key) == 0) {
key = paste(.TEMP_KEY, ".", .pkg.env$temp_count, sep="")
.pkg.env$temp_count = (.pkg.env$temp_count + 1) %% .RESULT_MAX
.pkg.env$temp_count = (.pkg.env$temp_count + 1) %% .pkg.env$RESULT_MAX
}

# TODO: Be careful, there might be a limit on how long a vector you can define in console
Expand Down
10 changes: 8 additions & 2 deletions R/h2o-package/R/Internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
.pkg.env = new.env()
.pkg.env$result_count = 0
.pkg.env$temp_count = 0
.pkg.env$RESULT_MAX = 1000
.pkg.env$IS_LOGGING = FALSE

.TEMP_KEY = "Last.value"
.RESULT_MAX = 1000
.MAX_INSPECT_ROW_VIEW = 10000
.MAX_INSPECT_COL_VIEW = 10000
.LOGICAL_OPERATORS = c("==", ">", "<", "!=", ">=", "<=", "&", "|", "&&", "||", "!", "is.na")

"%p0%" <- function(x,y) assign(deparse(substitute(x)), paste(x, y, sep = ""), parent.frame()) # paste0
"%p%" <- function(x,y) assign(deparse(substitute(x)), paste(x, y), parent.frame()) # paste

# Function to manage temp key wrapping behavior
h2o.setMaxLastValue <- function(val = 1000000000) {
assign("RESULT_MAX", val, envir = .pkg.env)
print(paste("Set h2o .pkg.env$RESULT_MAX to", .pkg.env$RESULT_MAX))
}

# Initialize functions for R logging
.myPath = paste(Sys.getenv("HOME"), "Library", "Application Support", "h2o", sep=.Platform$file.sep)
if(.Platform$OS.type == "windows")
Expand Down Expand Up @@ -393,7 +399,7 @@ h2o.setLogPath <- function(path, type) {
#------------------------------------ Exec2 ------------------------------------#
.h2o.__exec2 <- function(client, expr) {
destKey = paste(.TEMP_KEY, ".", .pkg.env$temp_count, sep="")
.pkg.env$temp_count <- (.pkg.env$temp_count + 1) %% .RESULT_MAX
.pkg.env$temp_count <- (.pkg.env$temp_count + 1) %% .pkg.env$RESULT_MAX
.h2o.__exec2_dest_key(client, expr, destKey)
# .h2o.__exec2_dest_key(client, expr, .TEMP_KEY)
}
Expand Down

0 comments on commit c4f64c4

Please sign in to comment.