Operating modes and high-level API

Learn about the operating modes that are typically used by the client-side code, such as the Netezza R Library package functions.

The following operating modes are typically used by the client-side code, such as the Netezza R Library package functions:
run
Performs the user-provided function without modification.
apply
Calls the user-provided function for each row of the input table and applies it to the input data stream.
tapply
Applies the user-provided function on groups of rows that are passed as data.frames.
install
Installs an R extension package that is provided by the user on Host and SPUs.
groupedapply
Applies a user-provided function on a number of data subsets that are created based on a user-specified GROUP BY clause.
Each of these modes assumes that the user provides a number of input objects, such as a mode identifier, the function itself with any additional arguments in a strictly specified format .
Note: The meaning of the term mode as it pertains to R depends on the context. Here, it refers to a high-level server-side R function that accepts a number of user-provided parameters, that is, a function with optional arguments. These functions control the part of the flow that is not directly related to data processing, for example, the loop that builds an input row, then passes it to the user-provided function, and outputs the result of the function. All modes, except for run, hide part of the low-level API from the user.
The following example shows the apply mode:
# we assume that 'fun' is the user-provided function
while (getNext()) {
row <- list()
for (i in seq(inputColumnCount()))
row[[i]] <- getInputColumn(i-1)
ret <- do.call(fun, c(list(x=row), args))
if (length(ret)) {
for (i in 1:length(ret))
setOutput(i-1, ret[[i]])
outputResult()
}
}