reduceSummary.keys

Property Description

Holds the keys that were passed to the reduce stage, either by the map stage, if it was used, or by the getInputData stage.

These keys are listed in lexicographical order.

Type

iterator

Since

2015.2

Members

Member

Type

Required/Optional

Description

iterator().each(parameters)

function

required

Executes one time for each key.

parameters

Member

Type

Required/Optional

Description

iteratorFunction(key, executionCount, completionState)

See also functionParameters.

function

required

Provides logic to be executed during each iteration.

functionParameters

Parameter

Type

Required/Optional

Description

key

string

optional

Represents a key that was passed to the reduce stage.

executionCount

number

optional

The number of times the reduce function was invoked for the key.

completionState

string

optional

A setting that indicates whether the map function was executed successfully for the key. Possible values are ‘COMPLETE’, ‘FAILED’, and ‘PENDING.’

The system uses ‘PENDING’ if the script exited the stage before trying to process the key. This behavior can occur when exitOnError is set to true.

Syntax

The following snippets show several ways you could use the reduceSummary.keys iterator. The code in the section is not a functional example. For a complete script example, see Map/Reduce Script Samples.

          //Add additional code.
...

// Create a single log entry listing all of the keys that were passed to the reduce stage. 

var reduceKeys = [];
                
summary.reduceSummary.keys.iterator().each(function (key){
    reduceKeys.push(key);
    return true;
});
                
log.debug({
    title: 'Reduce stage keys',
    details: reduceKeys
});


// Create a log entry for each key. The entry shows whether the reduce function was executed successfully for that key.

summary.reduceSummary.keys.iterator().each(function (key, executionCount, completionState){

log.debug({
    title: 'Reduce key ' + key,
    details: 'Outcome for reduce key ' + key + ': ' + completionState + ' // Number of attempts used: ' + executionCount
});

return true;

});


// creates a single log entry showing the total number of keys for which the reduce function was invoked successfully. 

var reduceKeysProcessed = 0;
summary.reduceSummary.keys.iterator().each(function (key, executionCount, completionState){
                                          
if (completionState === 'COMPLETE'){                              
    reduceKeysProcessed++;
}

return true;

});

log.debug({
    title: 'Reduce key statistics', 
    details: 'Total number of reduce keys processed successfully: ' + reduceKeysProcessed
});                  

...
//Add additional code. 

        

Related Topics

General Notices