jstests/libs/profiler.js
// Given a command, build its expected shape in the system profiler.
Given a command, build its expected shape in the system profiler.
Given a command build its expected shape in the system profiler .
function buildCommandProfile(command, sharded) {
    let commandProfile = {};
    if (command.mapReduce) {
        commandProfile["command.aggregate"] = command.mapReduce;
    } else if (command.update) {
        assert(command.updates.length == 1);
        for (let key in command.updates[0]) {
            commandProfile["command." + key] = command.updates[0][key];
        }
        commandProfile["command.upsert"] = commandProfile["command.upsert"] || false;
        commandProfile["command.multi"] = commandProfile["command.multi"] || false;
    } else if (command.delete) {
        assert(command.deletes.length == 1);
        for (let key in command.deletes[0]) {
            commandProfile["command." + key] = command.deletes[0][key];
        }
    } else {
        for (let key in command) {
            commandProfile["command." + key] = command[key];
        }
    }
    return commandProfile;
}
function buildCommandProfile ( command , sharded ) { let commandProfile = { } ; if ( command . mapReduce ) { commandProfile [ "command.aggregate" ] = command . mapReduce ; } else if ( command . update ) { assert ( command . updates . length == 1 ) ; for ( let key in command . updates [ 0 ] ) { commandProfile [ "command." + key ] = command . updates [ 0 ] [ key ] ; } commandProfile [ "command.upsert" ] = commandProfile [ "command.upsert" ] || false ; commandProfile [ "command.multi" ] = commandProfile [ "command.multi" ] || false ; } else if ( command . delete ) { assert ( command . deletes . length == 1 ) ; for ( let key in command . deletes [ 0 ] ) { commandProfile [ "command." + key ] = command . deletes [ 0 ] [ key ] ; } } else { for ( let key in command ) { commandProfile [ "command." + key ] = command [ key ] ; } } return commandProfile ; }
Given a command, build its expected shape in the system profiler.
Given a command build its expected shape in the system profiler .
// MapReduce is rewritten to an aggregate pipeline. // Updates are batched, but only allow using buildCommandProfile() for an update batch that // contains a single update, since the profiler generates separate entries for each update // in the batch. // Though 'upsert' and 'multi' are optional fields, they are written with the default value // in the profiler. // Deletes are batched, but only allow using buildCommandProfile() for a delete batch that // contains a single delete, since the profiler generates separate entries for each delete // in the batch.