orch.keyvals

Outputs a set of key-value pairs in a MapReduce job.

Usage

orch.keyvals(
        key,
        value)

Arguments

key

A scalar value.

value

A data structure such as a scalar, list, data frame, or vector.

Usage Notes

This function can only be used in the mapper, reducer, or combiner arguments of hadoop.exec and hadoop.run. Because the orch.keyvals function is not exposed in the ORCH client API, you cannot call it anywhere else.

Return Value

(key, value) structures

Example

This code fragment creates a mapper function using orch.keyval and a reducer function using orch.keyvals:

hadoop.run(data,
     mapper(k,v) {
          if (v$value > 10) {
               orch.keyval(k, v)
          }
          else {
               NULL
          }
     },
     reducer(k,vals) {
          orch.keyvals(k,vals)
}
)

The following code fragment shows orch.keyval in a for loop to perform the same reduce operation as orch.keyvals in the previous example:

     reducer(k,vals) {
          out <- list()
          for (v in vals) {
               out <- list(out, orch.keyval(k,vals))
          }
          out
     }