This is an interface that defines the operations available on a
Backend implementation. Backend implementations and the
Context class must implement this interface.
new()Create a new BackendService object.
BackendService$new()Instantiating this class will throw an error.
specificationAn object of class Specification
that contains the backend configuration.
This method returns void. The resulting backend must be stored in the
.cluster private field on the Backend abstract class,
and accessible to any concrete backend implementations via the active
binding cluster.
This method returns void.
clear()Remove all objects from the backend. This function is equivalent to
calling rm(list = ls(all.names = TRUE)) on each node in the
backend.
BackendService$clear()This method is ran by default when the backend is started.
This method returns void.
peek()Inspect the backend for variables available in the .GlobalEnv.
BackendService$peek()This method returns a list of character vectors, where each element
corresponds to a node in the backend. The character vectors contain
the names of the variables available in the .GlobalEnv on each
node.
export()Export variables from a given environment to the backend.
BackendService$export(variables, environment)variablesA character vector of variable names to export.
environmentAn environment object from which to export the variables.
This method returns void.
evaluate()Evaluate an arbitrary expression on the backend.
BackendService$evaluate(expression)expressionAn unquoted expression to evaluate on the backend.
This method returns the result of the expression evaluation.
sapply()Run a task on the backend akin to parallel::parSapply().
BackendService$sapply(x, fun, ...)xAn atomic vector or list to pass to the fun function.
funA function to apply to each element of x.
...Additional arguments to pass to the fun function.
This method returns void. The output of the task execution must be
stored in the private field .output on the Backend
abstract class, and is accessible via the get_output() method.
lapply()Run a task on the backend akin to parallel::parLapply().
BackendService$lapply(x, fun, ...)xAn atomic vector or list to pass to the fun function.
funA function to apply to each element of x.
...Additional arguments to pass to the fun function.
This method returns void. The output of the task execution must be
stored in the private field .output on the Backend
abstract class, and is accessible via the get_output() method.
apply()Run a task on the backend akin to parallel::parApply().
BackendService$apply(x, margin, fun, ...)xAn array to pass to the fun function.
marginA numeric vector indicating the dimensions of x the
fun function should be applied over. For example, for a matrix,
margin = 1 indicates applying fun rows-wise, margin = 2
indicates applying fun columns-wise, and margin = c(1, 2)
indicates applying fun element-wise. Named dimensions are also
possible depending on x. See parallel::parApply() and
base::apply() for more details.
funA function to apply to x according to the margin.
...Additional arguments to pass to the fun function.
This method returns void. The output of the task execution must be
stored in the private field .output on the Backend
abstract class, and is accessible via the get_output() method.
get_output()Get the output of the task execution.
BackendService$get_output(...)...Additional optional arguments that may be used by concrete implementations.
This method fetches the output of the task execution after calling
the sapply() method. It returns the output and immediately removes
it from the backend. Therefore, subsequent calls to this method are
not advised. This method should be called after the execution of a
task.
A vector, matrix, or list of the same length as x, containing the
results of the fun. The output format differs based on the specific
operation employed. Check out the documentation for the apply
operations of parallel::parallel for more information.
clone()The objects of this class are cloneable with this method.
BackendService$clone(deep = FALSE)deepWhether to make a deep clone.
Backend, SyncBackend, AsyncBackend,
and Context.