Outputs a set of key-value pairs in a MapReduce job.
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.
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 }