map(mapContext)
Description |
Executes when the The logic in your map function is applied to each key-value pair that is provided by the getInputData stage. One key-value pair is processed per function invocation, then the function is invoked again for the next pair. The output of the map stage is another set of key-value pairs. During the shuffle stage that always follows, these pairs are automatically grouped by key. For information about the context object provided to this entry point, see mapContext. |
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 mapContext 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 mapContext.errors.
In the summary stage, you can review all map stage errors by using mapSummary.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.
// Add additional code
...
function map(context)
{
for (var i = 0; context.value && i < context.value.length; i++)
if (context.value[i] !=== ' ' && !PUNCTUATION_REGEXP.test(context.value[i]))
{
context.write({
key: context.value[i],
value: 1
});
}
}
...
// Add additional code