mapContext.executionNo

Property Description

Indicates whether the current invocation of the map(mapContext) function is the first or a subsequent invocation for the current key-value pair.

For an overview of events that can cause a restart, see System Response After a Map/Reduce Interruption.

When the map function is restarted for a key-value pair, data previously written by the incomplete function is deleted. However, some of the function’s logic might have been executed before the function invocation was interrupted. For that reason, you may want to use the mapContext.executionNo property to provide logic designed to avoid duplicate processing.

For examples of how to write a robust map/reduce script, see Adding Logic to Handle Map/Reduce Restarts.

Related properties include mapContext.isRestarted and mapContext.errors.

Type

number

Since

2018.1

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
...

if (context.executionNo === 1){
    // Permit full processing of the key-value pair.
}

else if (context.executionNo === 2){
    // Take steps to check whether any processing was previously completed.
}
              
else {
    // Take other steps that might be necessary in the case of more than
    // one previous attempt.                    
}
...
// Add additional code 

        

Related Topics

mapContext
mapContext.isRestarted
mapContext.errors
mapContext.key
mapContext.value
mapContext.write(options)

General Notices