reduce(reduceContext)
Description |
Executes when the reduce entry point is triggered. The logic in your reduce function is applied to each key, and its corresponding list of value. Only one key, with its corresponding values, is processed per function invocation. The function is invoked again for the next key and corresponding set of values. Data is provided to the reduce stage by one of the following:
For information about the context object provided to this entry point, see reduceContext. |
Returns |
Void |
Since |
2015.2 |
Parameters
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
Object |
Required |
Object that contains:
For a description of each property in this object, see reduceContext Object Members. |
Errors
When an error is thrown, the behavior of the job varies depending on the setting of the retryCount configuration option.
If the function has been restarted for a key-value pair that it previously attempted to process, any errors logged during prior attempts can be accessed through reduceContext.errors.
In the summary stage, you can review all reduce stage errors by using reduceSummary.errors.
Syntax
The following code snippet shows the syntax for this member. It is not a functional example. For a complete script example, see Map/Reduce Script Samples.
...
function reduce(context)
{
context.write({
key: context.key ,
value: context.values.length
});
}
...