map(mapContext)

Description

Runs when the map entry point is triggered.

Your map function's logic is applied to each key-value pair from the getInputData stage. Each function call processes one pair, then runs again for the next.

The map stage outputs another set of key-value pairs. In the shuffle stage, 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

mapContext

Object

Required

Object that contains:

  • The key-value pairs to process in the map stage.

  • Logic to save data and pass it to the reduce stage.

  • Other properties you can use in the map function.

For a description of each property in this object, see mapContext Object Members.

Errors

When an error is thrown, the job's behavior depends on the retryCount setting.

If the function restarts for a key-value pair it already tried to process, you can see any past errors in 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's not a functional example. For a complete script example, see SuiteScript 2.x Map/Reduce Script Code 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 

          

Related Topics

General Notices