R/zzz.R

Defines functions .onAttach set_rqdatatable_as_executor

Documented in set_rqdatatable_as_executor

# don't let . look like an unbound reference
. = NULL


#' Set rqdatatable package as default rquery executor
#'
#' Sets rqdatatable (and hence data.table) as the default executor for rquery).
#'
#' @export
#'
set_rqdatatable_as_executor <- function() {
  options(list("rquery.rquery_executor" = list(f = ex_data_table, name = "rqdatable")))
  invisible(NULL)
}


.onAttach <- function(libname, pkgname) {
  # attach happens after load, so set as the executor only in the attach case
  prev_exec <- getOption("rquery.rquery_executor", default = NULL)
  if(is.null(prev_exec) || (is.list(prev_exec) && isTRUE(prev_exec$name == "rqdatable"))) {
    set_rqdatatable_as_executor()
  }
  cur_exec <- getOption("rquery.rquery_executor", default = NULL)
  if(isTRUE(cur_exec$name == "rqdatable")) {
    # don't multi-thread unless user sets thread higher, safer during CRAN checks
    data.table::setDTthreads(1)
  }
  invisible(NULL)
}

Try the rqdatatable package in your browser

Any scripts or data that you put into this service are public.

rqdatatable documentation built on Aug. 21, 2023, 9:10 a.m.