Control flow
The R Language Adapter consists of the R interpreter, the R-to-Netezza connection layer
that includes an R-side package that is called nzrserver and Netezza Analytic
Executables shared libraries, and a number of R-implemented high-level functions.
Each time an SQL query that references the R Language Adapter is started, a new R session is
started, which starts the R interpreter, loads the necessary packages. At a minimum,
nzrserver with its dependencies reads the user-provided R code and runs the
code.
You might run R AE in one of the following ways:
- The R AE is started on Host, as a single process as
follows:
This processing occurs whenSELECT * FROM TABLE WITH FINAL(nzr..r_udtf(1, 2.0, 'text', 'WORKSPACE_PATH=rfile'));- Only literals, that is constant values, are passed to the UDX.
- One or more table columns are passed to the UDX. but the optimizer gathers the whole table on Host to speed up the execution.
- A number of R sessions are started on all SPUs (subordinate nodes) and each R integer instance
operates only on this part of the input table which is located on the respective
SPU.
This processing occurs when an actual table is passed to the UDX and optimizer decides to run the query in parallel.SELECT * FROM input_table,TABLE WITH FINAL(nzr..r_udtf(input_table.col_a, input_table.col_b, 'WORKSPACE_PATH=rfile'));
The process is started once for the whole partition. The part of data located on a dataslice), and not separately for each row. This means that sharing and aggregating data across rows is possible.
An Analytic Executable process is expected to acquire the desired number of input rows, from zero
to the size of its partition, and output:
- Exactly one value in UDF mode.
- From zero to any number of rows in UDTF mode.
The data flow is controlled mainly by the
getNext function, which returns TRUE
when an input row is available for
processing.while(getNext()) { # process input data # return some output}